diff options
author | Werner Koch <wk@gnupg.org> | 2013-12-12 15:13:09 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-12-12 15:28:06 +0100 |
commit | 3b30e9840d4b351c4de73b126e561154cb7df4cc (patch) | |
tree | ef3d2d1127165ef5866840d33ccde9d35a2dee33 /cipher/dsa-common.c | |
parent | cd548ba2dc777b8b27d8d33182ba733c20222120 (diff) | |
download | libgcrypt-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/dsa-common.c')
-rw-r--r-- | cipher/dsa-common.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/cipher/dsa-common.c b/cipher/dsa-common.c index da29dd32..d251eae8 100644 --- a/cipher/dsa-common.c +++ b/cipher/dsa-common.c @@ -53,7 +53,7 @@ _gcry_dsa_gen_k (gcry_mpi_t q, int security_level) { if ( !rndbuf || nbits < 32 ) { - gcry_free (rndbuf); + xfree (rndbuf); rndbuf = _gcry_random_bytes_secure (nbytes, security_level); } else @@ -64,7 +64,7 @@ _gcry_dsa_gen_k (gcry_mpi_t q, int security_level) thus we better use this simple method. */ char *pp = _gcry_random_bytes_secure (4, security_level); memcpy (rndbuf, pp, 4); - gcry_free (pp); + xfree (pp); } _gcry_mpi_set_buffer (k, rndbuf, nbytes, 0); @@ -95,7 +95,7 @@ _gcry_dsa_gen_k (gcry_mpi_t q, int security_level) } break; /* okay */ } - gcry_free (rndbuf); + xfree (rndbuf); return k; } @@ -120,7 +120,7 @@ int2octets (unsigned char **r_frame, gcry_mpi_t value, size_t nbytes) noff = (nframe < nbytes)? nbytes - nframe : 0; n = nframe + noff; - frame = mpi_is_secure (value)? gcry_malloc_secure (n) : gcry_malloc (n); + frame = mpi_is_secure (value)? xtrymalloc_secure (n) : xtrymalloc (n); if (!frame) return gpg_err_code_from_syserror (); if (noff) @@ -129,7 +129,7 @@ int2octets (unsigned char **r_frame, gcry_mpi_t value, size_t nbytes) rc = _gcry_mpi_print (GCRYMPI_FMT_USG, frame+noff, nframe-noff, NULL, value); if (rc) { - gcry_free (frame); + xfree (frame); return rc; } @@ -200,7 +200,7 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, return GPG_ERR_DIGEST_ALGO; /* Step b: V = 0x01 0x01 0x01 ... 0x01 */ - V = gcry_malloc (hlen); + V = xtrymalloc (hlen); if (!V) { rc = gpg_err_code_from_syserror (); @@ -210,7 +210,7 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, V[i] = 1; /* Step c: K = 0x00 0x00 0x00 ... 0x00 */ - K = gcry_calloc (1, hlen); + K = xtrycalloc (1, hlen); if (!K) { rc = gpg_err_code_from_syserror (); @@ -265,7 +265,7 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, memcpy (V, _gcry_md_read (hd, 0), hlen); /* Step h. */ - t = gcry_malloc ((qbits+7)/8+hlen); + t = xtrymalloc ((qbits+7)/8+hlen); if (!t) { rc = gpg_err_code_from_syserror (); @@ -346,12 +346,12 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, /* log_mpidump (" k", k); */ leave: - gcry_free (t); + xfree (t); _gcry_md_close (hd); - gcry_free (h1_buf); - gcry_free (x_buf); - gcry_free (K); - gcry_free (V); + xfree (h1_buf); + xfree (x_buf); + xfree (K); + xfree (V); if (rc) mpi_free (k); |