diff options
Diffstat (limited to 'pathspec.c')
-rw-r--r-- | pathspec.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pathspec.c b/pathspec.c index 9304ee33d7..24e0dd5232 100644 --- a/pathspec.c +++ b/pathspec.c @@ -406,7 +406,8 @@ void parse_pathspec(struct pathspec *pathspec, n++; pathspec->nr = n; - pathspec->items = item = xmalloc(sizeof(*item) * n); + ALLOC_ARRAY(pathspec->items, n); + item = pathspec->items; pathspec->_raw = argv; prefixlen = prefix ? strlen(prefix) : 0; @@ -483,12 +484,12 @@ const char **get_pathspec(const char *prefix, const char **pathspec) void copy_pathspec(struct pathspec *dst, const struct pathspec *src) { *dst = *src; - dst->items = xmalloc(sizeof(struct pathspec_item) * dst->nr); + ALLOC_ARRAY(dst->items, dst->nr); memcpy(dst->items, src->items, sizeof(struct pathspec_item) * dst->nr); } -void free_pathspec(struct pathspec *pathspec) +void clear_pathspec(struct pathspec *pathspec) { free(pathspec->items); pathspec->items = NULL; |