]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/mv.c
use st_add and st_mult for allocation size computation
[thirdparty/git.git] / builtin / mv.c
index d1d43168ae79d0157f8adf9dc36a4d2683afe91b..aeae855e2b95399db4ae6032d118848449488267 100644 (file)
@@ -24,7 +24,8 @@ static const char **internal_copy_pathspec(const char *prefix,
                                           int count, unsigned flags)
 {
        int i;
-       const char **result = xmalloc((count + 1) * sizeof(const char *));
+       const char **result;
+       ALLOC_ARRAY(result, count + 1);
        memcpy(result, pathspec, count * sizeof(const char *));
        result[count] = NULL;
        for (i = 0; i < count; i++) {
@@ -47,9 +48,9 @@ static const char **internal_copy_pathspec(const char *prefix,
 
 static const char *add_slash(const char *path)
 {
-       int len = strlen(path);
+       size_t len = strlen(path);
        if (path[len - 1] != '/') {
-               char *with_slash = xmalloc(len + 2);
+               char *with_slash = xmalloc(st_add(len, 2));
                memcpy(with_slash, path, len);
                with_slash[len++] = '/';
                with_slash[len] = 0;