changeset 69:8f6d3850fac1

Remove useless attributes and add [P]ARRAY_FULL
author David Demelier <markand@malikania.fr>
date Fri, 11 Nov 2011 02:21:59 +0100
parents 18e8c7911825
children 580d76781c9e
files array.h parray.h
diffstat 2 files changed, 36 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/array.h	Thu Nov 10 20:34:02 2011 +0100
+++ b/array.h	Fri Nov 11 02:21:59 2011 +0100
@@ -23,15 +23,6 @@
 extern "C" {
 #endif
 
-/* Add some nonnull attributes for gcc/clang */
-#ifdef __GNUC__
-#  define __at_malloc		__attribute__ ((malloc))
-#  define __at_nonnull(...)	__attribute__ ((nonnull (__VA_ARGS__)))
-#else
-#  define __at_malloc
-#  define __at_nonnull(...)
-#endif
-
 #define ARRAY_DEFAULT_BSIZE	128
 
 enum array_type {
@@ -52,20 +43,20 @@
 typedef void (*array_map_fn)(void *, void *);
 typedef int (*array_cmp_fn)(void *, void *);
 
-struct array	*array_new(enum array_type, size_t, int) __at_malloc;
-int		array_push(struct array *, const void *) __at_nonnull(1, 2);
-int		array_insert(struct array *, const void *, int) __at_nonnull(1, 2);
-int		array_append(struct array *, const void *) __at_nonnull(1, 2);
-void		array_pop(struct array *) __at_nonnull(1);
-void		array_unqueue(struct array *) __at_nonnull(1);
-void		array_remove(struct array *, int) __at_nonnull(1);
-void		array_unref(struct array *, const void *) __at_nonnull(1);
-int		array_iswap(struct array *, int, int) __at_nonnull(1);
-int		array_pswap(struct array *, const void *, const void *) __at_nonnull(1);
-void		array_map(const struct array *, array_map_fn, void *) __at_nonnull(1, 2);
-int		array_find(const struct array *, array_cmp_fn, void *, void *) __at_nonnull(1, 2);
-void		array_clear(struct array *) __at_nonnull(1);
-void		array_free(struct array *) __at_nonnull(1);
+struct array	*array_new(enum array_type, size_t, int);
+int		array_push(struct array *, const void *);
+int		array_insert(struct array *, const void *, int);
+int		array_append(struct array *, const void *);
+void		array_pop(struct array *);
+void		array_unqueue(struct array *);
+void		array_remove(struct array *, int);
+void		array_unref(struct array *, const void *);
+int		array_iswap(struct array *, int, int);
+int		array_pswap(struct array *, const void *, const void *);
+void		array_map(const struct array *, array_map_fn, void *);
+int		array_find(const struct array *, array_cmp_fn, void *, void *);
+void		array_clear(struct array *);
+void		array_free(struct array *);
 
 #define ARRAY_HEAD(a, type)							\
 	(((type *)a->data)[0])
@@ -84,6 +75,10 @@
 		(a)->i < (a)->length;						\
 		++(a)->i, var = ARRAY_INDEX((a), (a)->i, type))
 
+/* Only for ARRAY_FIXED */
+#define ARRAY_FULL(a)								\
+	((a)->length == (a)->bsize)
+
 #ifdef __cplusplus
 }
 #endif
--- a/parray.h	Thu Nov 10 20:34:02 2011 +0100
+++ b/parray.h	Fri Nov 11 02:21:59 2011 +0100
@@ -23,15 +23,6 @@
 extern "C" {
 #endif
 
-/* Add some nonnull attributes for gcc/clang */
-#ifdef __GNUC__
-#  define __at_malloc		__attribute__ ((malloc))
-#  define __at_nonnull(...)	__attribute__ ((nonnull (__VA_ARGS__)))
-#else
-#  define __at_malloc
-#  define __at_nonnull(...)
-#endif
-
 #define PARRAY_DEFAULT_BSIZE	128
 
 enum parray_type {
@@ -51,20 +42,20 @@
 typedef void (*parray_map_fn)(void *, void *);
 typedef int (*parray_cmp_fn)(void *, void *);
 
-struct parray	*parray_new(enum parray_type, int)  __at_malloc;
-int		parray_push(struct parray *, void *) __at_nonnull(1);
-int		parray_insert(struct parray *, void *, int) __at_nonnull(1);
-int		parray_append(struct parray *, void *) __at_nonnull(1);
-void		parray_pop(struct parray *) __at_nonnull(1);
-void		parray_unqueue(struct parray *) __at_nonnull(1);
-void		parray_remove(struct parray *, int) __at_nonnull(1);
-void		parray_unref(struct parray *, const void *) __at_nonnull(1);
-int		parray_iswap(struct parray *, int, int) __at_nonnull(1);
-int		parray_pswap(struct parray *, const void *, const void *) __at_nonnull(1);
-void		parray_map(const struct parray *, parray_map_fn, void *) __at_nonnull(1, 2);
-int		parray_find(const struct parray *, parray_cmp_fn, void **, void *) __at_nonnull(1, 2);
-void		parray_clear(struct parray *) __at_nonnull(1);
-void		parray_free(struct parray *) __at_nonnull(1);
+struct parray	*parray_new(enum parray_type, int);
+int		parray_push(struct parray *, void *);
+int		parray_insert(struct parray *, void *, int);
+int		parray_append(struct parray *, void *);
+void		parray_pop(struct parray *);
+void		parray_unqueue(struct parray *);
+void		parray_remove(struct parray *, int);
+void		parray_unref(struct parray *, const void *);
+int		parray_iswap(struct parray *, int, int);
+int		parray_pswap(struct parray *, const void *, const void *);
+void		parray_map(const struct parray *, parray_map_fn, void *);
+int		parray_find(const struct parray *, parray_cmp_fn, void **, void *);
+void		parray_clear(struct parray *);
+void		parray_free(struct parray *);
 
 #define PARRAY_HEAD(a)								\
 	(a->datas[0])
@@ -83,6 +74,10 @@
 	for ((a)->i = 0, var = PARRAY_INDEX((a), (a)->i);			\
 	    (a)->i < (a)->length; ++(a)->i, var = PARRAY_INDEX((a), (a)->i))
 
+/* Only for PARRAY_FIXED */
+#define PARRAY_FULL(a)								\
+	((a)->length == (a)->bsize)
+
 #define PARRAY_FLUSH(a)								\
 do {										\
 	void *i;								\