summaryrefslogtreecommitdiff
path: root/src/global.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 /src/global.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 'src/global.c')
-rw-r--r--src/global.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/global.c b/src/global.c
index 8a5d3100..cb66d371 100644
--- a/src/global.c
+++ b/src/global.c
@@ -827,7 +827,7 @@ do_malloc (size_t n, unsigned int flags, void **mem)
}
void *
-gcry_malloc (size_t n)
+_gcry_malloc (size_t n)
{
void *mem = NULL;
@@ -837,7 +837,7 @@ gcry_malloc (size_t n)
}
void *
-gcry_malloc_secure (size_t n)
+_gcry_malloc_secure (size_t n)
{
void *mem = NULL;
@@ -847,7 +847,7 @@ gcry_malloc_secure (size_t n)
}
int
-gcry_is_secure (const void *a)
+_gcry_is_secure (const void *a)
{
if (get_no_secure_memory ())
return 0;
@@ -871,17 +871,17 @@ _gcry_check_heap( const void *a )
}
void *
-gcry_realloc (void *a, size_t n)
+_gcry_realloc (void *a, size_t n)
{
void *p;
/* To avoid problems with non-standard realloc implementations and
our own secmem_realloc, we divert to malloc and free here. */
if (!a)
- return gcry_malloc (n);
+ return _gcry_malloc (n);
if (!n)
{
- gcry_free (a);
+ xfree (a);
return NULL;
}
@@ -895,7 +895,7 @@ gcry_realloc (void *a, size_t n)
}
void
-gcry_free (void *p)
+_gcry_free (void *p)
{
int save_errno;
@@ -916,7 +916,7 @@ gcry_free (void *p)
}
void *
-gcry_calloc (size_t n, size_t m)
+_gcry_calloc (size_t n, size_t m)
{
size_t bytes;
void *p;
@@ -929,14 +929,14 @@ gcry_calloc (size_t n, size_t m)
return NULL;
}
- p = gcry_malloc (bytes);
+ p = _gcry_malloc (bytes);
if (p)
memset (p, 0, bytes);
return p;
}
void *
-gcry_calloc_secure (size_t n, size_t m)
+_gcry_calloc_secure (size_t n, size_t m)
{
size_t bytes;
void *p;
@@ -949,7 +949,7 @@ gcry_calloc_secure (size_t n, size_t m)
return NULL;
}
- p = gcry_malloc_secure (bytes);
+ p = _gcry_malloc_secure (bytes);
if (p)
memset (p, 0, bytes);
return p;
@@ -961,17 +961,17 @@ gcry_calloc_secure (size_t n, size_t m)
secure memory as well. In an out-of-memory condition, NULL is
returned. */
char *
-gcry_strdup (const char *string)
+_gcry_strdup (const char *string)
{
char *string_cp = NULL;
size_t string_n = 0;
string_n = strlen (string);
- if (gcry_is_secure (string))
- string_cp = gcry_malloc_secure (string_n + 1);
+ if (_gcry_is_secure (string))
+ string_cp = _gcry_malloc_secure (string_n + 1);
else
- string_cp = gcry_malloc (string_n + 1);
+ string_cp = _gcry_malloc (string_n + 1);
if (string_cp)
strcpy (string_cp, string);
@@ -981,11 +981,11 @@ gcry_strdup (const char *string)
void *
-gcry_xmalloc( size_t n )
+_gcry_xmalloc( size_t n )
{
void *p;
- while ( !(p = gcry_malloc( n )) )
+ while ( !(p = _gcry_malloc( n )) )
{
if ( fips_mode ()
|| !outofcore_handler
@@ -998,16 +998,16 @@ gcry_xmalloc( size_t n )
}
void *
-gcry_xrealloc( void *a, size_t n )
+_gcry_xrealloc( void *a, size_t n )
{
void *p;
- while ( !(p = gcry_realloc( a, n )) )
+ while ( !(p = _gcry_realloc( a, n )) )
{
if ( fips_mode ()
|| !outofcore_handler
|| !outofcore_handler (outofcore_handler_value, n,
- gcry_is_secure(a)? 3:2 ) )
+ _gcry_is_secure(a)? 3:2))
{
_gcry_fatal_error (gpg_err_code_from_errno (errno), NULL );
}
@@ -1016,11 +1016,11 @@ gcry_xrealloc( void *a, size_t n )
}
void *
-gcry_xmalloc_secure( size_t n )
+_gcry_xmalloc_secure( size_t n )
{
void *p;
- while ( !(p = gcry_malloc_secure( n )) )
+ while ( !(p = _gcry_malloc_secure( n )) )
{
if ( fips_mode ()
|| !outofcore_handler
@@ -1035,7 +1035,7 @@ gcry_xmalloc_secure( size_t n )
void *
-gcry_xcalloc( size_t n, size_t m )
+_gcry_xcalloc( size_t n, size_t m )
{
size_t nbytes;
void *p;
@@ -1047,13 +1047,13 @@ gcry_xcalloc( size_t n, size_t m )
_gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
}
- p = gcry_xmalloc ( nbytes );
+ p = _gcry_xmalloc ( nbytes );
memset ( p, 0, nbytes );
return p;
}
void *
-gcry_xcalloc_secure( size_t n, size_t m )
+_gcry_xcalloc_secure( size_t n, size_t m )
{
size_t nbytes;
void *p;
@@ -1065,20 +1065,20 @@ gcry_xcalloc_secure( size_t n, size_t m )
_gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
}
- p = gcry_xmalloc_secure ( nbytes );
+ p = _gcry_xmalloc_secure ( nbytes );
memset ( p, 0, nbytes );
return p;
}
char *
-gcry_xstrdup (const char *string)
+_gcry_xstrdup (const char *string)
{
char *p;
- while ( !(p = gcry_strdup (string)) )
+ while ( !(p = _gcry_strdup (string)) )
{
size_t n = strlen (string);
- int is_sec = !!gcry_is_secure (string);
+ int is_sec = !!_gcry_is_secure (string);
if (fips_mode ()
|| !outofcore_handler