### 4.3 Error handler

The following functions may be used to register handler functions that are called by Libgcrypt in case certain error conditions occur. They may and should be registered prior to calling `gcry_check_version`.

Data type: gcry_handler_no_mem_t

  This type is defined as: `int (*gcry_handler_no_mem_t) (void *, size_t, unsigned int)`

Function: void gcry_set_outofcore_handler (gcry_handler_no_mem_t func_no_mem, void *cb_data)

  This function registers func_no_mem as ‘out-of-core handler’, which means that it will be called in the case of not having enough memory available. The handler is called with 3 arguments: The first one is the pointer cb_data as set with this function, the second is the requested memory size and the last being a flag. If bit 0 of the flag is set, secure memory has been requested. The handler should either return true to indicate that Libgcrypt should try again allocating memory or return false to let Libgcrypt use its default fatal error handler.

Data type: gcry_handler_error_t

  This type is defined as: `void (*gcry_handler_error_t) (void *, int, const char *)`

Function: void gcry_set_fatalerror_handler (gcry_handler_error_t func_error, void *cb_data)

  This function registers func_error as ‘error handler’, which means that it will be called in error conditions.