[ekg2-commit] ekg2: commands.c (HEAD) [darkjames]

CVS commit cvs w toxygen.net
Czw, 22 Lis 2007, 17:21:27 CET


Module name:	ekg2
Changes by:	darkjames	2007-11-22 17:21:25

Modified files:
	commands.c

Log message:
command_t list and previous patch. just sample.

Index: commands.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/commands.c,v
diff -d -u -r1.296 -r1.297
--- commands.c	1 Nov 2007 23:24:08 -0000	1.296
+++ commands.c	22 Nov 2007 16:21:25 -0000	1.297
@@ -4188,6 +4188,11 @@
 	return LIST_ADD_SORTED(&commands, c, 0, command_add_compare);
 }
 
+static LIST_FREE_ITEM(list_command_free, command_t *) {
+	array_free(data->params);
+	array_free(data->possibilities);
+}
+
 /*
  * command_remove()
  *
@@ -4197,13 +4202,8 @@
  *  - name - nazwa komendy.
  */
 
-void command_freeone(command_t *c)
-{
-	if (!c)
-		return;
-	array_free(c->params);
-	array_free(c->possibilities);
-	list_remove(&commands, c, 1);
+void command_freeone(command_t *c) {
+	LIST_REMOVE(&commands, c, list_command_free);
 }
 
 int command_remove(plugin_t *plugin, const char *name)
@@ -4216,6 +4216,7 @@
 
 		if (!xstrcasecmp(name, c->name) && plugin == c->plugin) {
 			command_freeone(c);
+
 			return 0;
 		}
 	}
@@ -4223,6 +4224,20 @@
 	return -1;
 }
 
+/**
+ * command_free()
+ *
+ * Free <b>all</b> commands
+ *
+ * @sa command_freeone() 	- To free one command [with know pointer to it]
+ * @sa command_remove()		- To free command [with known plugin and name]
+ */
+
+void command_free() {
+	LIST_DESTROY(commands, list_command_free);
+	commands = NULL;
+}
+
 /*
  * rodzaje parametrów komend:
  *
@@ -4403,32 +4418,6 @@
 	commands_lock = NULL;
 }
 
-/**
- * command_free()
- *
- * Free <b>all</b> commands
- *
- * @sa command_freeone() 	- To free one command [with know pointer to it]
- * @sa command_remove()		- To free command [with known plugin and name]
- */
-
-void command_free() {
-	list_t l;
-
-	if (!commands)
-		return;
-
-	for (l = commands; l; l = l->next) {
-		command_t *c = l->data;
-
-		array_free(c->params);
-		array_free(c->possibilities);
-	}
-
-	list_destroy(commands, 1);
-	commands = NULL;
-}
-
 /*
  * Local Variables:
  * mode: c


Więcej informacji o liście dyskusyjnej ekg2-commit