changeset 9:1fbcbd58742e

move destroyall to array.h
author David A. Holland
date Sun, 19 Dec 2010 19:19:02 -0500
parents 97243badae69
children 800f3a560a3b
files array.h files.c
diffstat 2 files changed, 20 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/array.h	Sun Dec 19 19:15:55 2010 -0500
+++ b/array.h	Sun Dec 19 19:19:02 2010 -0500
@@ -227,6 +227,24 @@
 #define DECLARRAY(T) DECLARRAY_BYTYPE(T##array, struct T)
 #define DEFARRAY(T, INLINE) DEFARRAY_BYTYPE(T##array, struct T, INLINE)
 
+#define DESTROYALL_ARRAY(T, INLINE) \
+	void T##array_destroyall(struct T##array *arr);	\
+							\
+	INLINE void					\
+	T##array_destroyall(struct T##array *arr)	\
+	{						\
+		unsigned i, num;			\
+		struct T *t;				\
+							\
+		num = T##array_num(arr);		\
+		for (i=0; i<num; i++) {			\
+			t = T##array_get(arr, i);	\
+			T##_destroy(t);			\
+		}					\
+		T##array_setsize(arr, 0);		\
+	}
+
+
 ////////////////////////////////////////////////////////////
 // basic array types
 
--- a/files.c	Sun Dec 19 19:15:55 2010 -0500
+++ b/files.c	Sun Dec 19 19:19:02 2010 -0500
@@ -31,22 +31,6 @@
 ////////////////////////////////////////////////////////////
 // management
 
-#define DESTROYALL(T) \
-	static						\
-	void						\
-	T##array_destroyall(struct T##array *arr)	\
-	{						\
-		unsigned i, num;			\
-		struct T *t;				\
-							\
-		num = T##array_num(arr);		\
-		for (i=0; i<num; i++) {			\
-			t = T##array_get(arr, i);	\
-			T##_destroy(t);			\
-		}					\
-		T##array_setsize(arr, 0);		\
-	}
-
 static
 struct incdir *
 incdir_create(const char *name, bool issystem)
@@ -94,8 +78,8 @@
 	incdirarray_init(&bracketpath);
 }
 
-DESTROYALL(incdir);
-DESTROYALL(seenfile);
+DESTROYALL_ARRAY(incdir, );
+DESTROYALL_ARRAY(seenfile, );
 
 void
 files_cleanup(void)