From ca2baa3f7532dfe1816b623f39489ed10f3c9a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 3 Sep 2016 17:59:15 +0200 Subject: compat: move strdup(3) replacement to its own file 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 Signed-off-by: Junio C Hamano --- compat/strdup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 compat/strdup.c (limited to 'compat/strdup.c') diff --git a/compat/strdup.c b/compat/strdup.c new file mode 100644 index 000000000..f3fb978eb --- /dev/null +++ b/compat/strdup.c @@ -0,0 +1,11 @@ +#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; +} -- cgit v1.2.1