[ekg2-commit] r4083 - trunk/ekg: trunk/ekg/commands.c trunk/ekg/dynstuff_inline.h trunk/ekg/scripts.c trunk/ekg/stuff.c
SVN commit
svn w toxygen.net
Śro, 9 Lip 2008, 17:44:44 CEST
Author: darkjames
Date: 2008-07-09 17:44:43 +0200 (Wed, 09 Jul 2008)
New Revision: 4083
Modified:
trunk/ekg/commands.c
trunk/ekg/dynstuff_inline.h
trunk/ekg/scripts.c
trunk/ekg/stuff.c
Log:
scripts, scriptlang, ekg_converters.
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-07-09 15:04:45 UTC (rev 4082)
+++ trunk/ekg/commands.c 2008-07-09 15:44:43 UTC (rev 4083)
@@ -4144,8 +4144,7 @@
for (c = commands; c; c = c->next) {
if (!xstrcasecmp(name, c->name) && plugin == c->plugin) {
- commands_remove(c);
-
+ (void) commands_removei(c);
return 0;
}
}
Modified: trunk/ekg/dynstuff_inline.h
===================================================================
--- trunk/ekg/dynstuff_inline.h 2008-07-09 15:04:45 UTC (rev 4082)
+++ trunk/ekg/dynstuff_inline.h 2008-07-09 15:44:43 UTC (rev 4083)
@@ -377,15 +377,19 @@
#define DYNSTUFF_LIST_DECLARE(lista, type, free_func, list_add, list_remove, list_destroy) \
DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, __DYNSTUFF_NOCOUNT)
+#define DYNSTUFF_LIST_DECLARE_NF(lista, type, list_add, list_unlink) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT)
+
#define DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, list_count) \
DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, list_count)
+#define DYNSTUFF_LIST_DECLARE_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_destroy) \
+ DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
+
+
#define DYNSTUFF_LIST_DECLARE2(lista, type, free_func, list_add, list_remove, list_remove2, list_destroy) \
DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
-#define DYNSTUFF_LIST_DECLARE_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_destroy) \
- DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
-
#define DYNSTUFF_LIST_DECLARE2_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_destroy) \
DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
Modified: trunk/ekg/scripts.c
===================================================================
--- trunk/ekg/scripts.c 2008-07-09 15:04:45 UTC (rev 4082)
+++ trunk/ekg/scripts.c 2008-07-09 15:44:43 UTC (rev 4083)
@@ -14,6 +14,7 @@
#include "debug.h"
#include "dynstuff.h"
+#include "dynstuff_inline.h"
#include "scripts.h"
#include "xmalloc.h"
@@ -31,8 +32,19 @@
*/
script_t *scripts;
+
+static LIST_FREE_ITEM(list_script_free, script_t *) { xfree(data->name); xfree(data->path); }
+DYNSTUFF_LIST_DECLARE(scripts, script_t, list_script_free,
+ static __DYNSTUFF_LIST_ADD, /* scripts_add() */
+ static __DYNSTUFF_LIST_REMOVE_SAFE, /* scripts_remove() */
+ __DYNSTUFF_NODESTROY)
+
scriptlang_t *scriptlang;
+DYNSTUFF_LIST_DECLARE_NF(scriptlang, scriptlang_t,
+ static __DYNSTUFF_LIST_ADD, /* scriptlang_add() */
+ static __DYNSTUFF_LIST_UNLINK) /* scriptlang_unlink() */
+
static list_t script_timers;
static list_t script_plugins;
static list_t script_vars;
@@ -67,7 +79,7 @@
int scriptlang_register(scriptlang_t *s)
{
- LIST_ADD2(&scriptlang, s);
+ scriptlang_add(s);
s->init();
@@ -80,7 +92,7 @@
{
script_unload_lang(s);
s->deinit();
- LIST_UNLINK2(&scriptlang, s);
+ scriptlang_unlink(s);
return 0;
}
@@ -287,9 +299,7 @@
print("script_removed", scr->name, scr->path, slang->name);
- xfree(scr->name);
- xfree(scr->path);
- LIST_REMOVE2(&scripts, scr, NULL);
+ scripts_remove(scr);
return 0;
}
@@ -393,7 +403,7 @@
scr->lang = slang;
scr->inited = 1;
- LIST_ADD2(&scripts, scr); /* BUG: this should be before `script_loaded`... */
+ scripts_add(scr); /* BUG: this should be before `script_loaded`... */
ret = slang->script_load(scr);
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-07-09 15:04:45 UTC (rev 4082)
+++ trunk/ekg/stuff.c 2008-07-09 15:44:43 UTC (rev 4083)
@@ -2862,6 +2862,13 @@
};
static struct ekg_converter *ekg_converters = NULL; /**< list for internal use of ekg_convert_string_*() */
+
+static LIST_FREE_ITEM(list_ekg_converter_free, struct ekg_converter *) { xfree(data->from); xfree(data->to); }
+DYNSTUFF_LIST_DECLARE(ekg_converters, struct ekg_converter, list_ekg_converter_free,
+ static __DYNSTUFF_LIST_ADD, /* ekg_converters_add() */
+ static __DYNSTUFF_LIST_REMOVE_ITER, /* ekg_converters_removei() */
+ __DYNSTUFF_NODESTROY) /* XXX? */
+
#endif
/**
@@ -2952,7 +2959,7 @@
c->is_utf = 2;
else if (!xstrcasecmp(c->from, "UTF-8"))
c->is_utf = 1;
- LIST_ADD2(&ekg_converters, c);
+ ekg_converters_add(c);
}
return cd;
@@ -3008,9 +3015,7 @@
c->to = tmp;
}
} else { /* else, free it */
- xfree(c->from);
- xfree(c->to);
- LIST_REMOVE2(&ekg_converters, c, NULL);
+ (void) ekg_converters_removei(c);
}
}
Więcej informacji o liście dyskusyjnej ekg2-commit