Re:Show HN: Parson, lighweight json parser in C
by thomaslee on Sunday October 28, 2012 @02:53PM
(#4709636)
strndup is part of the "standard", but not present on some platforms unfortunately. :( I can't think of a modern C runtime that doesn't offer strdup, though.
The realloc check is good advice -- take heed, OP. :)
Re:Show HN: Parson, lighweight json parser in C
by kgabis on Sunday October 28, 2012 @03:56PM
(#4709794)
Realloc, strdup and strndup errors are handled as of now :)
(https://github.com/kgabis/parson/commit/ee9be98974b3fdac0be1...)
And yes, I've written my own strndup because it's "relatively new".
I don't see why you duplicated strndup in parson_strndup.
https://github.com/kgabis/parson/blob/master/parson.c#L129
parson_strdup can return NULL and this statement will fail silently.