Mercurial > code
diff array.h @ 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 | cff6869fbc94 |
children | b3ba5f5df3b9 |
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