diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-09-09 05:17:24 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-09-09 05:17:24 +0000 |
commit | c472c61f649a0c291a72bd18d742d4e48c69be95 (patch) | |
tree | 57535c51f4d8193c5f44a74291628ddaaacf60c6 /lib/gnutls_mem.c | |
parent | c8d5c206ce66a0315e65161911a3328d9e3f40dd (diff) | |
download | gnutls-c472c61f649a0c291a72bd18d742d4e48c69be95.tar.gz |
Some fixes for the used realloc() function. Now we have gnutls_realloc_fast() which frees the given pointer if the new allocation failed.
Diffstat (limited to 'lib/gnutls_mem.c')
-rw-r--r-- | lib/gnutls_mem.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gnutls_mem.c b/lib/gnutls_mem.c index f4a7481855..340e82f19e 100644 --- a/lib/gnutls_mem.c +++ b/lib/gnutls_mem.c @@ -60,6 +60,24 @@ svoid *gnutls_secure_calloc(size_t nmemb, size_t size) return ret; } +/* This realloc will free ptr in case realloc + * fails. + */ +void* gnutls_realloc_fast( void* ptr, size_t size) +{ +void *ret; + + if (size == 0) return ptr; + + ret = gnutls_realloc( ptr, size); + if ( ret == NULL) { + gnutls_free( ptr); + return NULL; + } + + return ret; +} + char* _gnutls_strdup( const char* str) { int siz = strlen( str); char * ret; |