From: Charlie Brej Date: Mon, 29 Jun 2009 13:41:23 +0000 (+0100) Subject: [script] Creating a string object with a NULL string now returns a NULL object X-Git-Tag: 0.7.0~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7fad23f701d6f8c163fdbdf77b697c7b23b65c8;p=thirdparty%2Fplymouth.git [script] Creating a string object with a NULL string now returns a NULL object Strings in C are often set to NULL to signify that they have not been set. This should be carried through to the script system rather than failing at the conversion. --- diff --git a/src/plugins/splash/script/script-object.c b/src/plugins/splash/script/script-object.c index 115ad3fe..110810be 100644 --- a/src/plugins/splash/script/script-object.c +++ b/src/plugins/splash/script/script-object.c @@ -192,6 +192,13 @@ char* script_obj_print (script_obj* obj) } +script_obj* script_obj_new_null (void) +{ + script_obj* obj = malloc(sizeof(script_obj)); + obj->type = SCRIPT_OBJ_TYPE_NULL; + obj->refcount = 1; + return obj; +} script_obj* script_obj_new_int (int number) { @@ -213,6 +220,7 @@ script_obj* script_obj_new_float (float number) script_obj* script_obj_new_string (const char* string) { + if (!string) return script_obj_new_null (); script_obj* obj = malloc(sizeof(script_obj)); obj->type = SCRIPT_OBJ_TYPE_STRING; obj->refcount = 1; @@ -220,14 +228,6 @@ script_obj* script_obj_new_string (const char* string) return obj; } -script_obj* script_obj_new_null (void) -{ - script_obj* obj = malloc(sizeof(script_obj)); - obj->type = SCRIPT_OBJ_TYPE_NULL; - obj->refcount = 1; - return obj; -} - script_obj* script_obj_new_hash (void) { script_obj* obj = malloc(sizeof(script_obj));