diff options
Diffstat (limited to 'xdiff/xmacros.h')
| -rw-r--r-- | xdiff/xmacros.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/xdiff/xmacros.h b/xdiff/xmacros.h index 0977d1615a..8487bb396f 100644 --- a/xdiff/xmacros.h +++ b/xdiff/xmacros.h @@ -58,4 +58,14 @@ do { \ /* Allocate an array of nr zeroed out elements, returns NULL on failure */ #define XDL_CALLOC_ARRAY(p, nr) ((p) = xdl_calloc(nr, sizeof(*(p)))) +/* + * Ensure array p can accommodate at least nr elements, growing the + * array and updating alloc (which is the number of allocated + * elements) as necessary. Frees p and returns -1 on failure, returns + * 0 on success + */ +#define XDL_ALLOC_GROW(p, nr, alloc) \ + (-!((nr) <= (alloc) || \ + ((p) = xdl_alloc_grow_helper((p), (nr), &(alloc), sizeof(*(p)))))) + #endif /* #if !defined(XMACROS_H) */ |
