diff options
Diffstat (limited to 'pathspec.c')
-rw-r--r-- | pathspec.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pathspec.c b/pathspec.c index 9304ee33d7..49a53607bb 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,11 @@ 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); - memcpy(dst->items, src->items, - sizeof(struct pathspec_item) * dst->nr); + ALLOC_ARRAY(dst->items, dst->nr); + COPY_ARRAY(dst->items, src->items, dst->nr); } -void free_pathspec(struct pathspec *pathspec) +void clear_pathspec(struct pathspec *pathspec) { free(pathspec->items); pathspec->items = NULL; |