Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
archived/docs/xalloc.txt
2010-12-22 04:28:52 +01:00

42 lines
1.5 KiB
Text

xalloc - safe memory allocation
-------------------------------
This module implements malloc and friends + some extensions.
If `__DEBUG__` symbol is defined. The functions will provide extended
debug logic and kills the program (passing 0 as size to malloc for example).
The funtions will at all times kill the program if memory can't be allocated for
some reason, this makes the need for client-code to check for `NULL` pointers returned
by these functions redundant.
Functions
~~~~~~~~~
`xmalloc()`::
Just like malloc, this function allocates a block of memory of 'size' bytes. +
If compiled with the `__DEBUG__` symbol, the function will not allow zero size
`xmallocz()`::
Exactly like xmalloc but will initialize the block with zero's.
`xrealloc()`::
Reallocates a previous allocated block of memory to 'size' bytes. +
If compiled with the `__DEBUG__` symbol, the function will not allow zero size
`xstrdup()`::
Allocates and copies the string 's' to a new memory location and returns it to the user. +
If compiled with the `__DEBUG__` symbol, the function will not allow 's' to be a `NULL` pointer
`xmemdup()`::
Allocates and copies `len` bytes from `ptr` to a new memory location and returns it to the user. +
If compiled with the `__DEBUG__` symbol, the function will not allow 'ptr' to be a `NULL` pointer
`xfree()`::
Free's a previous allocated block (pointed to by 'ptr') that is allocated by xmalloc/malloc. +
If compiled with the `__DEBUG__` symbol, the function will not allow 'ptr' to be a NULL pointer