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,
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}
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);
* 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.
}
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;
-}
-
}
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)
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
+
* 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.
*
**/
* "-----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.
* 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.
*
**/
* 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.
*
**/
* '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.