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

CVS commit cvs w toxygen.net
Czw, 22 Lis 2007, 19:46:55 CET


Module name:	ekg2
Changes by:	darkjames	2007-11-22 19:46:52

Modified files:
	stuff.c

Log message:
buffer.

Index: stuff.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/stuff.c,v
diff -d -u -r1.215 -r1.216
--- stuff.c	27 Oct 2007 07:43:30 -0000	1.215
+++ stuff.c	22 Nov 2007 18:46:52 -0000	1.216
@@ -465,6 +465,12 @@
 	}
 }
 
+static LIST_FREE_ITEM(list_buffer_free, struct buffer *) {
+	xfree(data->line);
+	xfree(data->target);
+	xfree(data);
+}
+
 /**
  * buffer_add()
  *
@@ -492,9 +498,7 @@
 			b = l->data;
 			l = l->next;
 
-			xfree(b->line);
-			xfree(b->target);
-			list_remove(type, b, 1);
+			LIST_REMOVE(type, b, list_buffer_free);
 			bcount--;
 		}
 	}
@@ -547,9 +551,7 @@
 			b = l->data;
 			l = l->next;
 
-			xfree(b->line);
-			xfree(b->target);
-			list_remove(type, b, 1);
+			LIST_REMOVE(type, b, list_buffer_free);
 			bcount--;
 		}
 	}
@@ -601,19 +603,10 @@
  */
 
 void buffer_free(list_t *type) {
-	list_t l;
-
 	if (!type || !(*type))
 		return;
 
-	for (l = *type; l; l = l->next) {
-		struct buffer *b = l->data;
-
-		xfree(b->line);
-		xfree(b->target);
-	}
-
-	list_destroy(*type, 1);
+	LIST_DESTROY(*type, list_buffer_free);
 	*type = NULL;
 }
 


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