Commit Graph

5 Commits

Author SHA1 Message Date
Nicola Spanti (RyDroid)
e42bcbbada Very minor changes to C source code 2016-08-08 15:54:56 +02:00
Bastien Dejean
e4d526a403 Fix deheader warnings
Prior to this commit the output of deheader was:
	remove <stdlib.h> from ./jsmn.c
	in ./example/jsondump.c, realloc() portability requires <unistd.h>.
	in ./example/simple.c, strtol() portability requires <stdlib.h>.
	saw 4 files, 16 includes, 1 removable
2015-12-14 15:05:46 +01:00
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