Skip to content

Commit 137c6ea

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c415162 commit 137c6ea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

git-compat-util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,
331331
#ifdef __GLIBC_PREREQ
332332
#if __GLIBC_PREREQ(2, 1)
333333
#define HAVE_STRCHRNUL
334+
#define HAVE_MEMPCPY
334335
#endif
335336
#endif
336337

@@ -344,6 +345,14 @@ static inline char *gitstrchrnul(const char *s, int c)
344345
}
345346
#endif
346347

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+
347356
extern void release_pack_memory(size_t, int);
348357

349358
extern char *xstrdup(const char *str);

0 commit comments

Comments
 (0)