aboutsummaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-05-03 23:26:54 -0700
committerJunio C Hamano <junkio@cox.net>2007-05-03 23:26:54 -0700
commit9aae177a4adff326421e55c7c0f3138de15ce2c1 (patch)
treeca19b08ff373ea122f87c90d03d111b03a89921e /git-compat-util.h
parent50acc58914bf02217e55fdd739a844f2bfc45410 (diff)
parente3ad95a8be82663d27cb501eaf9bad86a30f9cda (diff)
downloadgit-9aae177a4adff326421e55c7c0f3138de15ce2c1.tar.gz
git-9aae177a4adff326421e55c7c0f3138de15ce2c1.tar.xz
Merge branch 'maint'
* maint: gitweb: use decode_utf8 directly posix compatibility for t4200 Document 'opendiff' value in config.txt and git-mergetool.txt Allow PERL_PATH="/usr/bin/env perl" Make xstrndup common diff.c: fix "size cache" handling. http-fetch: Disable use of curl multi support for libcurl < 7.16.
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 2c84016ac..c08688c8f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -197,6 +197,19 @@ static inline void *xmalloc(size_t size)
return ret;
}
+static inline char *xstrndup(const char *str, size_t len)
+{
+ char *p;
+
+ p = memchr(str, '\0', len);
+ if (p)
+ len = p - str;
+ p = xmalloc(len + 1);
+ memcpy(p, str, len);
+ p[len] = '\0';
+ return p;
+}
+
static inline void *xrealloc(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);