docs: update strbuf and added xalloc.
This commit is contained in:
parent
4ca920dc01
commit
c5458d982b
2 changed files with 41 additions and 0 deletions
|
|
@ -55,6 +55,10 @@ strbuf_squeeze():
|
||||||
|
|
||||||
Squeezes "together" sequences of 'ch' into one character.
|
Squeezes "together" sequences of 'ch' into one character.
|
||||||
|
|
||||||
|
strbuf_term():
|
||||||
|
|
||||||
|
ensure the string is terminated with 'ch'. will not change the string if it is already terminated.
|
||||||
|
|
||||||
strbuf_release():
|
strbuf_release():
|
||||||
|
|
||||||
This function should be used to detach the ->buf member from the strbuf_t structure.
|
This function should be used to detach the ->buf member from the strbuf_t structure.
|
||||||
|
|
|
||||||
37
docs/xalloc.txt
Normal file
37
docs/xalloc.txt
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
-----------------------------------
|
||||||
|
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.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
xfree():
|
||||||
|
|
||||||
|
free's a previous allocated block pointed 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
|
||||||
Reference in a new issue