Next: , Previous: Progress handler, Up: Handler Functions

4.2 Allocation handler

It is possible to make Libgcrypt use special memory allocation functions instead of the built-in ones.

Memory allocation functions are of the following types:

— Data type: gcry_handler_alloc_t

This type is defined as: void *(*gcry_handler_alloc_t) (size_t n).

— Data type: gcry_handler_secure_check_t

This type is defined as: int *(*gcry_handler_secure_check_t) (const void *).

— Data type: gcry_handler_realloc_t

This type is defined as: void *(*gcry_handler_realloc_t) (void *p, size_t n).

— Data type: gcry_handler_free_t

This type is defined as: void *(*gcry_handler_free_t) (void *).

Special memory allocation functions can be installed with the following function:

— Function: void gcry_set_allocation_handler (gcry_handler_alloc_t func_alloc, gcry_handler_alloc_t func_alloc_secure, gcry_handler_secure_check_t func_secure_check, gcry_handler_realloc_t func_realloc, gcry_handler_free_t func_free)

Install the provided functions and use them instead of the built-in functions for doing memory allocation.