diff options
Diffstat (limited to 'android/utils/system.h')
-rw-r--r-- | android/utils/system.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/android/utils/system.h b/android/utils/system.h index 804aa7d..5053786 100644 --- a/android/utils/system.h +++ b/android/utils/system.h @@ -14,6 +14,12 @@ #include <string.h> #include <stdint.h> +#include "android/utils/assert.h" + +/* internal helpers */ +void* _android_array_alloc( size_t itemSize, size_t count ); +void* _android_array_alloc0( size_t itemSize, size_t count ); +void* _android_array_realloc( void* block, size_t itemSize, size_t count ); /* the following functions perform 'checked allocations', i.e. * they abort if there is not enough memory. @@ -42,10 +48,9 @@ void android_free( void* block ); #define AMEM_COPY(dst,src,size) memcpy((char*)(dst),(const char*)(src),(size_t)(size)) #define AMEM_MOVE(dst,src,size) memmove((char*)(dst),(const char*)(src),(size_t)(size)) -#define AARRAY_NEW(p,count) ((p) = android_alloc(sizeof(*p)*(count))) -#define AARRAY_NEW0(p,count) ((p) = android_alloc0(sizeof(*p)*(count))) - -#define AARRAY_RENEW(p,count) ((p) = android_realloc((p),sizeof(*(p))*(count))) +#define AARRAY_NEW(p,count) (AASSERT_LOC(), (p) = _android_array_alloc(sizeof(*p),(count))) +#define AARRAY_NEW0(p,count) (AASSERT_LOC(), (p) = _android_array_alloc0(sizeof(*p),(count))) +#define AARRAY_RENEW(p,count) (AASSERT_LOC(), (p) = _android_array_realloc((p),sizeof(*(p)),(count))) #define AARRAY_COPY(dst,src,count) AMEM_COPY(dst,src,(count)*sizeof((dst)[0])) #define AARRAY_MOVE(dst,src,count) AMEM_MOVE(dst,src,(count)*sizeof((dst)[0])) |