]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-compat-util.h
return the prune-packed progress display to the inner loop
[git.git] / git-compat-util.h
index 1bfbdeb94f55d57b429b91aa8762618153c34f7f..f23d934f667cc2b10ee668a3bfef8492aadbbe7d 100644 (file)
@@ -211,19 +211,20 @@ static inline void *xmalloc(size_t size)
        return ret;
 }
 
-static inline char *xstrndup(const char *str, size_t len)
+static inline void *xmemdupz(const void *data, size_t len)
 {
-       char *p;
-
-       p = memchr(str, '\0', len);
-       if (p)
-               len = p - str;
-       p = xmalloc(len + 1);
-       memcpy(p, str, len);
+       char *p = xmalloc(len + 1);
+       memcpy(p, data, len);
        p[len] = '\0';
        return p;
 }
 
+static inline char *xstrndup(const char *str, size_t len)
+{
+       char *p = memchr(str, '\0', len);
+       return xmemdupz(str, p ? p - str : len);
+}
+
 static inline void *xrealloc(void *ptr, size_t size)
 {
        void *ret = realloc(ptr, size);