Imported Upstream version 2.10.3
[platform/upstream/git.git] / pathspec.c
index 0be5edb..49a5360 100644 (file)
@@ -338,7 +338,7 @@ static void NORETURN unsupported_magic(const char *pattern,
                if (!(magic & m->bit))
                        continue;
                if (sb.len)
-                       strbuf_addstr(&sb, " ");
+                       strbuf_addch(&sb, ' ');
                if (short_magic & m->bit)
                        strbuf_addf(&sb, "'%c'", m->mnemonic);
                else
@@ -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;