--- projects/libstatgrab/src/libstatgrab/vector.h 2004/04/04 21:17:58 1.1 +++ projects/libstatgrab/src/libstatgrab/vector.h 2004/04/04 21:33:08 1.2 @@ -12,12 +12,7 @@ typedef struct { vector_destroy_function destroy_fn; } vector_header; -int statgrab_vector_resize(void **vector, vector_header *h, int count); - -/* Declare a vector. Specify the init/destroy functions as NULL if you don't - * need them. The block size is how many items to allocate at once. */ -#define VECTOR_DECLARE(name, item_type, block_size, init_fn, destroy_fn) \ - item_type * name = NULL; \ +#define VECTOR_HEADER(name, item_type, block_size, init_fn, destroy_fn) \ vector_header name##_header = { \ sizeof(item_type), \ 0, \ @@ -27,6 +22,19 @@ int statgrab_vector_resize(void **vector, vector_heade (vector_destroy_function) destroy_fn \ } +int statgrab_vector_resize(void **vector, vector_header *h, int count); + +/* Declare a vector. Specify the init/destroy functions as NULL if you don't + * need them. The block size is how many items to allocate at once. */ +#define VECTOR_DECLARE(name, item_type, block_size, init_fn, destroy_fn) \ + item_type *name = NULL; \ + VECTOR_HEADER(name, item_type, block_size, init_fn, destroy_fn) + +/* As VECTOR_DECLARE, but for a static vector. */ +#define VECTOR_DECLARE_STATIC(name, item_type, block_size, init_fn, destroy_fn) \ + static item_type *name = NULL; \ + static VECTOR_HEADER(name, item_type, block_size, init_fn, destroy_fn) + /* Return the current size of a vector. */ #define VECTOR_SIZE(name) \ name##_header.used_count @@ -40,5 +48,4 @@ int statgrab_vector_resize(void **vector, vector_heade /* Free a vector, destroying its contents. */ #define VECTOR_FREE(name) \ VECTOR_RESIZE(name, 0) -