20 lines
326 B
C
20 lines
326 B
C
#ifndef UTIL_H
|
|
#define UTIL_H
|
|
|
|
#define ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
|
|
#define ADDARRAY(a, e) \
|
|
do { \
|
|
if ((a ## num) >= (a ## max)) { \
|
|
if (!(a ## max)) \
|
|
(a ## max) = 16; \
|
|
else \
|
|
(a ## max) *= 2; \
|
|
(a) = realloc((a), (a ## max)*sizeof(*(a))); \
|
|
} \
|
|
(a)[(a ## num)++] = (e); \
|
|
} while(0)
|
|
|
|
|
|
#endif
|
|
|