summaryrefslogtreecommitdiff
path: root/cipher/ecc-curves.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-12-12 15:13:09 +0100
committerWerner Koch <wk@gnupg.org>2013-12-12 15:28:06 +0100
commit3b30e9840d4b351c4de73b126e561154cb7df4cc (patch)
treeef3d2d1127165ef5866840d33ccde9d35a2dee33 /cipher/ecc-curves.c
parentcd548ba2dc777b8b27d8d33182ba733c20222120 (diff)
downloadlibgcrypt-3b30e9840d4b351c4de73b126e561154cb7df4cc.tar.gz
Remove macro hacks for internal vs. external functions. Part 2 and last.
* src/visibility.h: Remove remaining define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by replacing them by the x-macros. * src/g10lib.h: Add internal prototypes. (xtrymalloc, xtrycalloc, xtrymalloc_secure, xtrycalloc_secure) (xtryrealloc, xtrystrdup, xmalloc, xcalloc, xmalloc_secure) (xcalloc_secure, xrealloc, xstrdup, xfree): New macros. -- The use of xmalloc/xtrymalloc/xfree is a more common pattern than the gcry_free etc. functions. Those functions behave like those defined by C and thus for better readability we use these macros and not the underscore prefixed functions. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/ecc-curves.c')
-rw-r--r--cipher/ecc-curves.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
index 85ebdd3f..ed629fcb 100644
--- a/cipher/ecc-curves.c
+++ b/cipher/ecc-curves.c
@@ -468,13 +468,13 @@ _gcry_ecc_update_curve_param (const char *name,
len += strlen (domain_parms[idx].g_x+2);
len += strlen (domain_parms[idx].g_y+2);
len++;
- buf = gcry_malloc (len);
+ buf = xtrymalloc (len);
if (!buf)
return gpg_err_code_from_syserror ();
strcpy (stpcpy (stpcpy (buf, "0x04"), domain_parms[idx].g_x+2),
domain_parms[idx].g_y+2);
*g = scanval (buf);
- gcry_free (buf);
+ xfree (buf);
}
if (model)
*model = domain_parms[idx].model;
@@ -545,7 +545,7 @@ _gcry_ecc_get_curve (gcry_sexp_t keyparms, int iterator, unsigned int *r_nbits)
goto leave; /* Name missing or out of core. */
idx = find_domain_parms_idx (name);
- gcry_free (name);
+ xfree (name);
if (idx >= 0) /* Curve found. */
{
result = domain_parms[idx].desc;
@@ -674,14 +674,14 @@ point_from_keyparam (gcry_mpi_point_t *r_a,
gcry_mpi_t y = NULL;
gcry_mpi_t z = NULL;
- tmpname = gcry_malloc (strlen (name) + 2 + 1);
+ tmpname = xtrymalloc (strlen (name) + 2 + 1);
if (!tmpname)
return gpg_err_code_from_syserror ();
strcpy (stpcpy (tmpname, name), ".x");
rc = mpi_from_keyparam (&x, keyparam, tmpname);
if (rc)
{
- gcry_free (tmpname);
+ xfree (tmpname);
return rc;
}
strcpy (stpcpy (tmpname, name), ".y");
@@ -689,7 +689,7 @@ point_from_keyparam (gcry_mpi_point_t *r_a,
if (rc)
{
mpi_free (x);
- gcry_free (tmpname);
+ xfree (tmpname);
return rc;
}
strcpy (stpcpy (tmpname, name), ".z");
@@ -698,7 +698,7 @@ point_from_keyparam (gcry_mpi_point_t *r_a,
{
mpi_free (y);
mpi_free (x);
- gcry_free (tmpname);
+ xfree (tmpname);
return rc;
}
if (!z)
@@ -712,7 +712,7 @@ point_from_keyparam (gcry_mpi_point_t *r_a,
mpi_free (z);
point = NULL;
}
- gcry_free (tmpname);
+ xfree (tmpname);
}
if (point)
@@ -810,19 +810,19 @@ _gcry_mpi_ec_new (gcry_ctx_t *r_ctx,
else
name = NULL;
- E = gcry_calloc (1, sizeof *E);
+ E = xtrycalloc (1, sizeof *E);
if (!E)
{
errc = gpg_err_code_from_syserror ();
- gcry_free (name);
+ xfree (name);
goto leave;
}
errc = _gcry_ecc_fill_in_curve (0, name? name : curvename, E, NULL);
- gcry_free (name);
+ xfree (name);
if (errc)
{
- gcry_free (E);
+ xfree (E);
goto leave;
}
@@ -857,7 +857,7 @@ _gcry_mpi_ec_new (gcry_ctx_t *r_ctx,
E->n = NULL;
}
_gcry_ecc_curve_free (E);
- gcry_free (E);
+ xfree (E);
}