diff --git a/docs/strbuf.txt b/docs/strbuf.txt index 474ff26..9f45b83 100644 --- a/docs/strbuf.txt +++ b/docs/strbuf.txt @@ -55,6 +55,10 @@ strbuf_squeeze(): 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(): This function should be used to detach the ->buf member from the strbuf_t structure. diff --git a/docs/xalloc.txt b/docs/xalloc.txt new file mode 100644 index 0000000..da1a3e9 --- /dev/null +++ b/docs/xalloc.txt @@ -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