diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-08-31 23:05:35 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-08-31 23:05:49 +0200 |
commit | 1f895a6ac8aa52d5a5d1b07257b27b62bfca86bb (patch) | |
tree | eddabc6695af999cb6bc48d259a773a53db0867f /include | |
parent | add _LIBRARY_HEADER (diff) | |
download | slibc-1f895a6ac8aa52d5a5d1b07257b27b62bfca86bb.tar.gz slibc-1f895a6ac8aa52d5a5d1b07257b27b62bfca86bb.tar.bz2 slibc-1f895a6ac8aa52d5a5d1b07257b27b62bfca86bb.tar.xz |
fix strdup functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/string.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/include/string.h b/include/string.h index 5891dbb..0a41899 100644 --- a/include/string.h +++ b/include/string.h @@ -23,7 +23,6 @@ #define __NEED_size_t -#define __NEED_wchar_t #define __NEED_locale_t /* TODO not defined */ #include <bits/types.h> @@ -656,7 +655,7 @@ void* memdup(const void*, size_t) const char* __s = (string); \ size_t __n = strlen(__s) + 1; \ char* __r = __builtin_alloca(__n * sizeof(char)); \ - memcpy(__r, __s, __n); \ + memcpy(__r, __s, __n * sizeof(char)); \ }) # endif @@ -678,7 +677,7 @@ void* memdup(const void*, size_t) const char* __s = (string); \ size_t __n = strnlen(__s, (maxlen)) + 1; \ char* __r = __builtin_alloca(__n * sizeof(char)); \ - memcpy(__r, __s, __n); \ + memcpy(__r, __s, __n * sizeof(char)); \ }) # endif @@ -694,11 +693,11 @@ void* memdup(const void*, size_t) * @return :size_t The new segment. There is no way to * detect whether the allocation failed. */ -# define memdupa(segment, size) \ - ({ \ - size_t __n = (size); \ - wchar_t* __r = __builtin_alloca(__n * sizeof(wchar_t)); \ - memcpy(__r, (segment), __n); \ +# define memdupa(segment, size) \ + ({ \ + size_t __n = (size); \ + void* __r = __builtin_alloca(__n); \ + memcpy(__r, (segment), __n); \ }) # endif # endif |