[unicode] Make _get_parent() return _nil object instead of NULL

This commit is contained in:
Behdad Esfahbod 2011-05-02 15:59:57 -04:00
parent 07e22779ab
commit c784c67a28
2 changed files with 13 additions and 18 deletions

View File

@ -110,8 +110,9 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
if (!(ufuncs = hb_object_create<hb_unicode_funcs_t> ())) if (!(ufuncs = hb_object_create<hb_unicode_funcs_t> ()))
return &_hb_unicode_funcs_nil; return &_hb_unicode_funcs_nil;
if (parent != NULL) if (!parent)
{ parent = &_hb_unicode_funcs_nil;
hb_unicode_funcs_make_immutable (parent); hb_unicode_funcs_make_immutable (parent);
ufuncs->parent = hb_unicode_funcs_reference (parent); ufuncs->parent = hb_unicode_funcs_reference (parent);
@ -121,11 +122,6 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
* onto it and it's immutable. We should not copy the destroy notifiers * onto it and it's immutable. We should not copy the destroy notifiers
* though. */ * though. */
ufuncs->user_data = parent->user_data; ufuncs->user_data = parent->user_data;
}
else
{
ufuncs->get = _hb_unicode_funcs_nil.get;
}
return ufuncs; return ufuncs;
} }
@ -149,7 +145,6 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
DESTROY (script); DESTROY (script);
#undef DESTROY #undef DESTROY
if (ufuncs->parent != NULL)
hb_unicode_funcs_destroy (ufuncs->parent); hb_unicode_funcs_destroy (ufuncs->parent);
free (ufuncs); free (ufuncs);
@ -190,7 +185,7 @@ hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
hb_unicode_funcs_t * hb_unicode_funcs_t *
hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs) hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs)
{ {
return ufuncs->parent; return ufuncs->parent ? ufuncs->parent : &_hb_unicode_funcs_nil;
} }

View File

@ -67,7 +67,7 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
{ {
data_t *data = (data_t *) user_data; data_t *data = (data_t *) user_data;
g_assert (hb_unicode_funcs_get_parent (ufuncs) == NULL); g_assert (hb_unicode_funcs_get_parent (ufuncs) != NULL);
g_assert (data->value == MAGIC0); g_assert (data->value == MAGIC0);
g_assert (data->freed == FALSE); g_assert (data->freed == FALSE);