summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-03-21 00:43:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-21 03:36:11 (GMT)
commit137c6eaa885a421346f0a5abbc3cc4903671fbeb (patch)
tree1f7fef06be4c675243e49fbea8a65e7f5960eea2 /git-compat-util.h
parentc4151629e7019d072cefdac992e164820ce9ed1c (diff)
downloadgit-137c6eaa885a421346f0a5abbc3cc4903671fbeb.zip
git-137c6eaa885a421346f0a5abbc3cc4903671fbeb.tar.gz
git-137c6eaa885a421346f0a5abbc3cc4903671fbeb.tar.bz2
compat: add mempcpy()
The mempcpy() function was added in glibc 2.1. It is quite handy, so add an implementation for cross-platform use. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index a3c4537..9bed5a0 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -331,6 +331,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 1)
#define HAVE_STRCHRNUL
+#define HAVE_MEMPCPY
#endif
#endif
@@ -344,6 +345,14 @@ static inline char *gitstrchrnul(const char *s, int c)
}
#endif
+#ifndef HAVE_MEMPCPY
+#define mempcpy gitmempcpy
+static inline void *gitmempcpy(void *dest, const void *src, size_t n)
+{
+ return (char *)memcpy(dest, src, n) + n;
+}
+#endif
+
extern void release_pack_memory(size_t, int);
extern char *xstrdup(const char *str);