From: Jonathan Nieder Date: Sun, 21 Mar 2010 00:43:32 +0000 (-0500) Subject: compat: add mempcpy() X-Git-Tag: v1.7.1-rc0~15^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=137c6eaa885a421346f0a5abbc3cc4903671fbeb;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-compat-util.h b/git-compat-util.h index a3c453736..9bed5a0b4 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);