Provided by: wget2-dev_1.99.1-2.2_amd64
NAME
libwget-xalloc - Memory allocation functions
SYNOPSIS
Functions void wget_set_oomfunc (void(*oom_callback)(void)) void * wget_malloc (size_t size) void * wget_calloc (size_t nmemb, size_t size) void * wget_realloc (void *ptr, size_t size) void wget_free (void *ptr)
Detailed Description
The provided memory allocation functions are used by explicit libwget memory allocations. They differ from the standard ones in that they exit the program in an out-of-memory situation with EXIT_FAILURE. That means, you don't have to check the returned value against NULL. You can provide a out-of-memory function that will be called before exit(), e.g. to print out a 'No memory' message. To work around this behavior, provide your own allocation routines, namely malloc(), calloc(), realloc().
Function Documentation
void wget_set_oomfunc (void(*)(void) oom_callback) Parameters oom_callback Pointer to your custom out-of-memory function Set a custom out-of-memory function. void* wget_malloc (size_t size) Parameters size Number of bytes to allocate Returns A pointer to the allocated (uninitialized) memory Like the standard malloc(), except that it doesn't return NULL values. If an out-of-memory condition occurs the oom callback function is called (if set). Thereafter the application is terminated by exit(EXIT_FAILURE); void* wget_calloc (size_t nmemb, size_t size) Parameters nmemb Number of elements (each of size size) to allocate size Size of element Returns A pointer to the allocated (initialized) memory Like the standard calloc(), except that it doesn't return NULL values. If an out-of-memory condition occurs the oom callback function is called (if set). Thereafter the application is terminated by exit(EXIT_FAILURE); void* wget_realloc (void * ptr, size_t size) Parameters ptr Pointer to old memory area size Number of bytes to allocate for the new memory area Returns A pointer to the new memory area Like the standard realloc(), except that it doesn't return NULL values. If an out-of- memory condition occurs or size is 0, the oom callback function is called (if set). Thereafter the application is terminated by exit(EXIT_FAILURE); void wget_free (void * ptr) Parameters ptr Pointer to memory-pointer to be freed This function is like free(). It is basically needed on systems where the library malloc heap is different from the caller's malloc heap, which happens on Windows when the library is a separate DLL. To prevent typical use-after-free issues, use the macro wget_xfree().
Author
Generated automatically by Doxygen for wget2 from the source code.