]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Exported the more convenient gnutls_malloc() and gnutls_free() functions. Actually...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 7 Dec 2002 11:19:53 +0000 (11:19 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 7 Dec 2002 11:19:53 +0000 (11:19 +0000)
NEWS
doc/tex/callbacks.tex
lib/gnutls.h.in.in
lib/gnutls_db.c
lib/gnutls_global.c
lib/gnutls_mem.c
lib/x509_b64.c
libextra/auth_srp_sb64.c
libextra/gnutls_srp.c

diff --git a/NEWS b/NEWS
index 27ad88764886d43596f880ab05a4a33199d53e4e..727c1b47946a6ea2b59c6b915bf8a48b237ecc13 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,10 +14,10 @@ Version 0.5.12
   than password files.
 - Added the function gnutls_openpgp_set_recv_key_function()
   which can be used to set a callback, to get OpenPGP keys.
-- Added the new functions:
-   gnutls_get_malloc_function()
-   gnutls_get_free_function()
-  to be used in callbacks.
+- Exported the functions:
+   gnutls_malloc()
+   gnutls_free()
+  which should be used in callbacks.
 - 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,
index 59f3fff8682006a3e531d26b872177641698c599..edd718a8023cdd5de276b43354fff9d7e0d070a7 100644 (file)
@@ -16,9 +16,8 @@ data to the transport layer.
 Other callback functions such as the one set by
 \printfunc{gnutls_srp_set_server_credentials_function}{gnutls\_srp\_set\_server\_credentials\_function},
 may require more complicated input, including data to be allocated.
-These callbacks should use the following function to get a malloc()
-and a free() like functions, to allocate data.
+These callbacks should allocate and free memory using the functions shown below.
 \begin{itemize}
-\item \printfunc{gnutls_global_get_malloc_function}{gnutls\_global\_get\_malloc\_function}
-\item \printfunc{gnutls_global_get_free_function}{gnutls\_global\_get\_free\_function}
+\item \printfunc{gnutls_malloc}{gnutls\_malloc}
+\item \printfunc{gnutls_free}{gnutls\_free}
 \end{itemize}
index 49da8fc2680fb6eca1faa2196ad164268433146a..5c5998bdf317a314325f7a01739e0735fb149474 100644 (file)
@@ -322,8 +322,8 @@ void gnutls_global_set_mem_functions(
        gnutls_free_function);
 
 /* For use in callbacks */
-gnutls_alloc_function gnutls_global_get_malloc_function(void);
-gnutls_free_function gnutls_global_get_free_function(void);
+extern gnutls_alloc_function gnutls_malloc;
+extern gnutls_free_function gnutls_free;
 
 typedef void (*gnutls_log_func)( const char*);
 void gnutls_global_set_log_function( gnutls_log_func log_func);
index 404afea8c52e24d1fb400f02f060a902f795bd19..3a67bdca61656adf12bdb95f1008abebeb82fe76 100644 (file)
@@ -39,8 +39,8 @@
   * sessions database. This function must return a gnutls_datum containing the
   * data on success, or a gnutls_datum containing null and 0 on failure.
   *
-  * The datum's data must be allocated using the function returned by
-  * gnutls_global_get_malloc_function().
+  * The datum's data must be allocated using the function
+  * gnutls_malloc().
   *
   * The first argument to store_function() will be null unless gnutls_db_set_ptr() 
   * has been called.
index fd225bda83a03b5eee66f44f94309d94e337af78..32a67af3744c4ced442a2cfb3de72487afd99f0b 100644 (file)
@@ -343,32 +343,3 @@ gnutls_check_version( const char *req_version )
     }
     return NULL;
 }
-
-/**
-  * gnutls_global_get_malloc_function - Returns a malloc() like function
-  * @session: is a &gnutls_session structure.
-  *
-  * This function will return a malloc() compatible function to be
-  * used by callbacks. The returned function is the one set by
-  * gnutls_global_set_mem_functions().
-  *
-  **/
-gnutls_alloc_function gnutls_global_get_malloc_function(void)
-{
-       return gnutls_malloc;
-}
-
-/**
-  * gnutls_global_get_free_function - Returns a free() like function
-  * @session: is a &gnutls_session structure.
-  *
-  * This function will return a free() compatible function to be
-  * used by callbacks. The returned function is the one set by
-  * gnutls_global_set_mem_functions().
-  *
-  **/
-gnutls_free_function gnutls_global_get_free_function(void)
-{
-       return gnutls_free;
-}
-
index 9dea5e3451ccd94eb13593bb8c3cba8f6111f5d4..05d204fdedab908149eb1b77b4dd6593ca38ae05 100644 (file)
@@ -79,8 +79,8 @@ void *ret;
 }
 
 char* _gnutls_strdup( const char* str) {
-int siz = strlen( str);
-char * ret;
+size_t siz = strlen( str);
+char* ret;
 
        ret = gnutls_malloc( siz + 1);
        if (ret == NULL)
@@ -91,3 +91,34 @@ char * ret;
        
        return ret;
 }
+
+
+#if 0
+/* don't use them. They are included for documentation.
+ */
+
+/**
+  * gnutls_malloc - Allocates and returns data
+  *
+  * This function will allocate 's' bytes data, and
+  * return a pointer to memory. This function is supposed
+  * to be used by callbacks.
+  *
+  * The allocation function used is the one set by gnutls_global_set_mem_functions().
+  *
+  **/
+void* gnutls_malloc( size_t s);
+
+/**
+  * gnutls_free - Returns a free() like function
+  * @d: pointer to memory
+  *
+  * This function will free data pointed by ptr.
+  *
+  * The deallocation function used is the one set by gnutls_global_set_mem_functions().
+  *
+  **/
+void gnutls_free( void* ptr);
+
+#endif
+
index 538b3e7eadd338f7256147795d2018f8534b2b56..145c11a538fd790062e1be6c750d7fe11f55bd81 100644 (file)
@@ -293,7 +293,7 @@ int size;
   * encoding. This is the encoding used in PEM messages. This function will
   * allocate the required memory to hold the encoded data.
   *
-  * You should use the function returned by gnutls_global_get_free_function() to
+  * You should use the function gnutls_free() to
   * free the returned data.
   * 
   **/
@@ -506,7 +506,7 @@ int size;
   * "-----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
+  * You should use the function gnutls_free() to
   * free the returned data.
   *
   * Note that b64_data should be null terminated.
index 2f3e313e8109fc7d144a9732712ede0bbb46d54c..bf9b160df089be853a91461c29488f3f511c32f2 100644 (file)
@@ -315,7 +315,7 @@ int size;
   * encoding. This is the encoding used in SRP password files. This function will
   * allocate the required memory to hold the encoded data.
   *
-  * You should use the function returned by gnutls_global_get_free_function() to
+  * You should use the function returned by gnutls_free() to
   * free the returned data.
   * 
   **/
@@ -385,7 +385,7 @@ int size;
   * will be allocated, and stored into result.
   * It will decode using the base64 algorithm found in libsrp.
   *
-  * You should use the function returned by gnutls_global_get_free_function() to
+  * You should use the function returned by gnutls_free() to
   * free the returned data.
   * 
   **/
index 32b921f452eed70c0cae914a93e18ce0f01153c4..9c042002c49a79311f033df8fbe71068a16d9ed9 100644 (file)
@@ -514,7 +514,7 @@ void gnutls_srp_server_set_select_function(gnutls_session session,
   * 'username' contains the actual username.
   *
   * The 'salt', 'verifier', 'generator' and 'prime' must be filled
-  * in using the malloc returned by gnutls_global_get_malloc_function().
+  * in using the gnutls_malloc().
   *
   * In case the callback returned a negative number then gnutls will
   * assume that the username does not exist.