Skip to content

Commit 546500f

Browse files
committed
Merge pull request #8 from estenberg/master
Revert json-change, add helper that can be used instead
2 parents 0496b1c + b7442ab commit 546500f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/json.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ void JsonObjectAppendString(JsonElement *object, const char *key, const char *va
173173
assert(object->type == JSON_ELEMENT_TYPE_CONTAINER);
174174
assert(object->container.type == JSON_CONTAINER_TYPE_OBJECT);
175175
assert(key);
176-
177-
if(!value)
178-
{
179-
value = "";
180-
}
176+
assert(value);
181177

182178
JsonElement *child = JsonElementCreatePrimitive(JSON_PRIMITIVE_TYPE_STRING, key, EscapeJsonString(value));
183179

src/string_lib.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,15 @@ long StringToLong(const char *str)
309309

310310
return result;
311311
}
312+
313+
/*********************************************************************/
314+
315+
char *NULLStringToEmpty(char *str)
316+
{
317+
if(!str)
318+
{
319+
return "";
320+
}
321+
322+
return str;
323+
}

src/string_lib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ char *ToLowerStr(const char *str);
3333
void ToLowerStrInplace(char *str);
3434

3535
long StringToLong(const char *str);
36+
char *NULLStringToEmpty(char *str);
3637

3738
bool IsNumber(const char *name);
3839

0 commit comments

Comments
 (0)