mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
ca2baa3f75
Move our implementation of strdup(3) out of compat/nedmalloc/ and allow it to be used independently from USE_NED_ALLOCATOR. The original nedmalloc doesn't come with strdup() and doesn't need it. Only _users_ of nedmalloc need it, which was added when we imported it to our compat/ hierarchy. This reduces the difference of our copy of nedmalloc from the original, making it easier to update, and allows for easier testing and reusing of our version of strdup(). Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 lines
169 B
C
12 lines
169 B
C
#include "../git-compat-util.h"
|
|
|
|
char *gitstrdup(const char *s1)
|
|
{
|
|
size_t len = strlen(s1) + 1;
|
|
char *s2 = malloc(len);
|
|
|
|
if (s2)
|
|
memcpy(s2, s1, len);
|
|
return s2;
|
|
}
|