mirror of
https://github.com/json-c/json-c.git
synced 2026-04-11 00:09:06 +08:00
Use strdup instead of strndup in test1.c, there's no need for the latter because json_object_to_json_string_length() will always return a properly sized string.
This commit is contained in:
@@ -35,7 +35,7 @@ static const char *to_json_string(json_object *obj, int flags)
|
|||||||
const char *result;
|
const char *result;
|
||||||
|
|
||||||
result = json_object_to_json_string_length(obj, flags, &length);
|
result = json_object_to_json_string_length(obj, flags, &length);
|
||||||
copy = strndup(result, length);
|
copy = strdup(result);
|
||||||
if (copy == NULL)
|
if (copy == NULL)
|
||||||
printf("to_json_string: Allocation failed!\n");
|
printf("to_json_string: Allocation failed!\n");
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user