From e7fad23f701d6f8c163fdbdf77b697c7b23b65c8 Mon Sep 17 00:00:00 2001 From: Charlie Brej Date: Mon, 29 Jun 2009 14:41:23 +0100 Subject: [PATCH] [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. --- src/plugins/splash/script/script-object.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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));