#define TAB_APPEND_CAST( cast, count, tab, p ) \
do { \
if( (count) > 0 ) \
- (tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
+ (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
else \
- (tab) = cast malloc( sizeof( void ** ) ); \
+ (tab) = cast malloc( sizeof( *(tab) ) ); \
if( !(tab) ) abort(); \
(tab)[count] = (p); \
(count)++; \
#define TAB_APPEND( count, tab, p ) \
TAB_APPEND_CAST( , count, tab, p )
-#define TAB_FIND( count, tab, p, index ) \
+#define TAB_FIND( count, tab, p, idx ) \
do { \
- (index) = -1; \
- for( int i = 0; i < (count); i++ ) \
- if( (tab)[i] == (p) ) \
- { \
- (index) = i; \
+ for( (idx) = 0; (idx) < (count); (idx)++ ) \
+ if( (tab)[(idx)] == (p) ) \
break; \
- } \
+ if( (idx) >= (count) ) \
+ (idx) = -1; \
} while(0)
{ \
memmove( ((void**)(tab) + i_index), \
((void**)(tab) + i_index+1), \
- ( (count) - i_index - 1 ) * sizeof( void* ) );\
+ ( (count) - i_index - 1 ) * sizeof( *(tab) ) );\
} \
(count)--; \
if( (count) == 0 ) \
#define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \
if( (count) > 0 ) \
- (tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
+ (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
else \
- (tab) = cast malloc( sizeof( void ** ) ); \
+ (tab) = cast malloc( sizeof( *(tab) ) ); \
if( !(tab) ) abort(); \
if( (count) - (index) > 0 ) \
memmove( (void**)(tab) + (index) + 1, \