[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.
This commit is contained in:
Charlie Brej 2009-06-29 14:41:23 +01:00 committed by Ray Strode
parent 5df19c2b1b
commit e7fad23f70

View file

@ -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));