Commit Graph

3 Commits

Author SHA1 Message Date
goriy
2d185aa465 tiny realloc function wrapper which handles cases of realloc failures
Memory reallocation with old data pointer handling is done by means
of realloc_it() function.

Tiny inline function realloc_it() is a wrapper function for standart
realloc() which frees old memory pointer and prints errno to stderr
if realloc fails.
2015-10-25 23:28:19 +03:00
goriy
e709651a20 small fix of jsondump example for cases of realloc failures
When realloc() function fails it returns NULL pointer.
But old data pointer remains valid in such a case.

It's a mistake to use old data pointer to store new
pointer returned by realloc. In case of realloc failure,
pointer is overwritten with NULL value, but old used memory
remains unreferenced and could not be even freed anymore.
Such mistakes could lead to memory leaks.
2015-10-24 23:32:51 +03:00
Serge A. Zaitsev
8a22e0a149 implemented key/value hierarchy; added 2 examples; fixed some warnings in tests 2014-11-17 14:13:58 +02:00