Steven Schubiger [Fri, 26 Apr 2013 21:18:05 +0000 (23:18 +0200)]
Introduce calloc wrappers and zero memory
Zero allocated memory of size "color name" struct to allow for
free() to be called for struct members even when not all of them
have been set explicitly yet. This is necessary since freeing
those might take place prematurely in cleanup() (triggered
via atexit).
In order to handle end-of-buffer reads with partial line chunks,
merge those when cleaning text. Pass each line then to the offset
extracting function which gathers begin/end offsets of escape
sequences. Finally, for printing cleaned lines of text, omit all
color escape sequences as defined by their set of offsets (and
restore characters temporarily overwritten with terminating NUL).
Furthermore, add a basic string concatenation function and wrap
the free memory function to have it nullify pointers.
Steven Schubiger [Thu, 24 Jan 2013 22:59:34 +0000 (23:59 +0100)]
Wrap memory allocation functions
This covers currently calls to malloc(), realloc() and the custom
strdup() (which uses malloc, too). If allocation of memory fails
(i.e., NULL is returned from one of former two calls), a fatal
diagnostic is emitted (accompanied by source filename and line
number if compiled with DEBUG=1).