diff options
| author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2022-07-08 16:25:18 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-07-08 09:34:30 -0700 |
| commit | 848fd5ae5b6506df50ae872302d94b794dc57d51 (patch) | |
| tree | e826df62795df5dd9b55b1f4aa0c38005e7a2294 /xdiff/xmacros.h | |
| parent | 18aae7e21e1a88c75adb38aa2555e0b1928b137d (diff) | |
| download | git-848fd5ae5b6506df50ae872302d94b794dc57d51.tar.gz | |
xdiff: introduce XDL_CALLOC_ARRAY()
Add a helper for allocating an array and initialize the elements to
zero. This is analogous to CALLOC_ARRAY() in the rest of the codebase
but it returns NULL on allocation failures rather than dying to
accommodate other users of libxdiff such as libgit2.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff/xmacros.h')
| -rw-r--r-- | xdiff/xmacros.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/xdiff/xmacros.h b/xdiff/xmacros.h index 9fd3c5da91..0977d1615a 100644 --- a/xdiff/xmacros.h +++ b/xdiff/xmacros.h @@ -55,4 +55,7 @@ do { \ ? xdl_malloc((nr) * sizeof(*(p))) \ : NULL) +/* Allocate an array of nr zeroed out elements, returns NULL on failure */ +#define XDL_CALLOC_ARRAY(p, nr) ((p) = xdl_calloc(nr, sizeof(*(p)))) + #endif /* #if !defined(XMACROS_H) */ |
