Fix the check when adding a new variable to the config parser, and NULL pointers...
authorDana Jansens <danakj@orodu.net>
Mon, 8 Aug 2011 18:17:24 +0000 (14:17 -0400)
committerDana Jansens <danakj@orodu.net>
Mon, 8 Aug 2011 19:15:31 +0000 (15:15 -0400)
- was checking if it didn't exist instead of looking for a duplicate

openbox/config_parser.c

index 941216b3ca7ec0ba0bd8b0b4914d5c8210efdbc3..887db07eaac1f8c6d3a5532c458e0878a0310f27 100644 (file)
@@ -125,9 +125,9 @@ static ObConfigParserEntity* add(ObConfigParser *p,
     ObConfigParserEntity *e;
 
     g_return_val_if_fail(def != NULL, NULL);
-    g_return_val_if_fail(g_hash_table_lookup(p->entities, name) != NULL, NULL);
+    g_return_val_if_fail(g_hash_table_lookup(p->entities, name) == NULL, NULL);
 
-    e = g_slice_new(ObConfigParserEntity);
+    e = g_slice_new0(ObConfigParserEntity);
     e->name = g_strdup(name);
     e->cb = FALSE;
     e->u.v.value = def;
@@ -251,9 +251,9 @@ void config_parser_callback(ObConfigParser *p, const gchar *name,
 {
     ObConfigParserEntity *e;
 
-    g_return_if_fail(g_hash_table_lookup(p->entities, name) != NULL);
+    g_return_if_fail(g_hash_table_lookup(p->entities, name) == NULL);
 
-    e = g_slice_new(ObConfigParserEntity);
+    e = g_slice_new0(ObConfigParserEntity);
     e->name = g_strdup(name);
     e->cb = TRUE;
     e->u.cb.func = cb;