X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Farray.h;h=b4dea94af489083e4e9f24e7e77159113fbe9e65;hb=9c710cd68a1826f033133240a944399adb28c4c0;hp=ed12b5b384566796ae90158236085abc9a9f7c2d;hpb=929bb1ca2452a5bc7410896fd4e5eea44901a0b7;p=apps%2Fpfixtools.git diff --git a/common/array.h b/common/array.h index ed12b5b..b4dea94 100644 --- a/common/array.h +++ b/common/array.h @@ -46,6 +46,22 @@ ssize_t len; \ ssize_t size; \ } + +#define PARRAY(Type) \ + typedef PRIV_ARRAY(Type*) Type ## _ptr_array_t; \ + static inline Type ## _ptr_array_t *Type ## _ptr_array_new(void) \ + { \ + return p_new(Type ## _ptr_array_t, 1); \ + } \ + \ + static inline void Type ## _ptr_array_delete(Type ## _ptr_array_t **array) \ + { \ + if (*array) { \ + array_wipe(**array); \ + p_delete(array); \ + } \ + } + #define ARRAY(Type) \ typedef PRIV_ARRAY(Type) Type ## _array_t; \ \ @@ -60,8 +76,12 @@ array_wipe(**array); \ p_delete(array); \ } \ - } + } \ + \ + PARRAY(Type) + #define A(Type) Type ## _array_t +#define PA(Type) Type ## _ptr_array_t #define ARRAY_INIT { NULL, 0, 0 } @@ -130,6 +150,9 @@ ARRAY(char) ARRAY(int) +ARRAY(bool) ARRAY(uint32_t) +PARRAY(void) + #endif