@matheusbsbs / matheus-bagliano / commits / 137c6eaa88
Fork 0

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>

Jonathan Nieder committed Mar 20, 2010 at 19:43 UTC 137c6eaa885a421346f0a5abbc3cc4903671fbeb
1 file changed +9
git-compat-util.h
+9
@@ -331,6 +331,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,
331 #ifdef __GLIBC_PREREQ
332 #if __GLIBC_PREREQ(2, 1)
333 #define HAVE_STRCHRNUL
334 +#define HAVE_MEMPCPY
335 #endif
336 #endif
337
@@ -344,6 +345,14 @@ static inline char *gitstrchrnul(const char *s, int c)
345 }
346 #endif
347
348 +#ifndef HAVE_MEMPCPY
349 +#define mempcpy gitmempcpy
350 +static inline void *gitmempcpy(void *dest, const void *src, size_t n)
351 +{
352 + return (char *)memcpy(dest, src, n) + n;
353 +}
354 +#endif
355 +
356 extern void release_pack_memory(size_t, int);
357
358 extern char *xstrdup(const char *str);