5 /* The "magic" mechanism was stolen from Evin Robertson's GtkGlk. */
8 magic_to_string(glui32 magic)
21 g_return_val_if_reached("unknown");
25 /* Internal function: check the object's magic number to make sure it is the
26 right type, and not freed. */
28 magic_is_valid_or_null(const glui32 goodmagic, const glui32 realmagic, const gchar *function)
30 if(realmagic != MAGIC_NULL)
32 if(realmagic != goodmagic)
34 if(realmagic == MAGIC_FREE)
35 g_critical("%s: Using a freed object", function);
37 g_critical( "%s: %s object not a %s", function, magic_to_string(realmagic), magic_to_string(goodmagic) );
45 /* Internal function: check the object's magic number to make sure it is
46 not NULL, the right type, and not freed. */
48 magic_is_valid(const void *obj, const glui32 goodmagic, const glui32 realmagic, const gchar *function)
52 g_critical( "%s: NULL %s pointer", function, magic_to_string(goodmagic) );
55 return magic_is_valid_or_null(goodmagic, realmagic, function);