diff options
Diffstat (limited to 'array.h')
| -rw-r--r-- | array.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1,6 +1,7 @@ #ifndef ARRAY_H_ #define ARRAY_H_ #include <stdlib.h> +#include <stdio.h> #include <stdbool.h> typedef struct { @@ -77,4 +78,14 @@ void* array_resize_(void* array, size_t item_size, size_t size); type__* CONCAT(it__, __LINE__) = array__; type__* CONCAT(end__, __LINE__) = array__ ? array__ + array_size(array__) : NULL; \ for (type__* name__; (CONCAT(it__, __LINE__) < CONCAT(end__, __LINE__)) ? (name__ = CONCAT(it__, __LINE__), true) : false; CONCAT(it__, __LINE__)++) +#define array_dump(array, type, name, fmt, ...) do { \ + array_print(array); \ + fprintf(stderr, "vals: \n"); \ + type* it__ = (array); type* end__ = (array) ? (array) + array_size(array) : NULL; \ + for (type* name; it__ < end__ ? (name = it__, true) : false; it__++) { \ + fprintf(stderr, fmt", ", __VA_ARGS__); \ + } \ + fprintf(stderr, "\b\b \n"); \ +} while (0) + #endif // ARRAY_H_ |
