diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-12-06 17:28:35 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-12-06 17:28:35 +0000 |
commit | e9ba5c4963ce480ffa49cb74d2ae3d985a097df0 (patch) | |
tree | 49297ab8f3f86b0f37a56a9fc9b9f54f9714a721 /lib/x509_b64.c | |
parent | 1d55c5755fdcc843020e1c05279a1cb3772f5a7a (diff) | |
download | gnutls-e9ba5c4963ce480ffa49cb74d2ae3d985a097df0.tar.gz |
Changed the semantics of gnutls_pem_base64_encode_alloc()
and gnutls_pem_base64_decode_alloc(). In the default case
were the gnutls library is used with malloc/realloc/free,
these are binary compatible.
They now require the returned data to be freed using
the gnutls_global_get_free_function().
Diffstat (limited to 'lib/x509_b64.c')
-rw-r--r-- | lib/x509_b64.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/lib/x509_b64.c b/lib/x509_b64.c index 3df4fd7cdb..538b3e7ead 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -291,7 +291,10 @@ int size; * * This function will convert the given data to printable data, using the base64 * encoding. This is the encoding used in PEM messages. This function will - * allocate (using malloc) the required memory to hold the encoded data. + * allocate the required memory to hold the encoded data. + * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. * **/ int gnutls_pem_base64_encode_alloc( const char* msg, const gnutls_datum *data, @@ -308,18 +311,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free(ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0; @@ -508,11 +501,14 @@ int size; * @result: the place where decoded data lie * * This function will decode the given encoded data. The decoded data - * will be allocated, using malloc, and stored into result. + * will be allocated, and stored into result. * If the header given is non null this function will search for * "-----BEGIN header" and decode only this part. Otherwise it will decode the * first PEM packet found. * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. + * * Note that b64_data should be null terminated. * **/ @@ -530,18 +526,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free( ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0; |