diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-19 13:51:42 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-19 13:51:42 -0700 |
commit | 815a73f7143214510fae6e8a2f2077b2e8694509 (patch) | |
tree | 1485e912318ae3f088a54190d448babb52b925c4 /compat | |
parent | 3d54b93f405c6881ac477c5bfec10802ea53f73d (diff) | |
parent | ca2baa3f7532dfe1816b623f39489ed10f3c9a49 (diff) | |
download | git-815a73f7143214510fae6e8a2f2077b2e8694509.tar.gz git-815a73f7143214510fae6e8a2f2077b2e8694509.tar.xz |
Merge branch 'rs/compat-strdup' into maint
Code cleanup.
* rs/compat-strdup:
compat: move strdup(3) replacement to its own file
Diffstat (limited to 'compat')
-rw-r--r-- | compat/nedmalloc/nedmalloc.c | 16 | ||||
-rw-r--r-- | compat/strdup.c | 11 |
2 files changed, 11 insertions, 16 deletions
diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c index 2d4ef5901..1cc31c350 100644 --- a/compat/nedmalloc/nedmalloc.c +++ b/compat/nedmalloc/nedmalloc.c @@ -948,22 +948,6 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void ** return ret; } -#ifdef OVERRIDE_STRDUP -/* - * This implementation is purely there to override the libc version, to - * avoid a crash due to allocation and free on different 'heaps'. - */ -char *strdup(const char *s1) -{ - size_t len = strlen(s1) + 1; - char *s2 = malloc(len); - - if (s2) - memcpy(s2, s1, len); - return s2; -} -#endif - #if defined(__cplusplus) } #endif 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; +} |