Skip to content

Commit

Permalink
compat: add mempcpy()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Mar 21, 2010
1 parent c415162 commit 137c6ea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
Expand Down

0 comments on commit 137c6ea

Please sign in to comment.