diff options
Diffstat (limited to '')
-rw-r--r-- | src/string/strdup.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string/strdup.c b/src/string/strdup.c index 27783b9..c65970e 100644 --- a/src/string/strdup.c +++ b/src/string/strdup.c @@ -33,7 +33,7 @@ char* strdup(const char* string) { size_t n = strlen(string) + 1; char* r = malloc(n * sizeof(char)); - return r == NULL ? NULL : memcpy(r, string, n); + return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); } @@ -55,7 +55,7 @@ char* strndup(const char* string, size_t maxlen) { size_t n = strnlen(string, maxlen) + 1; char* r = malloc(n * sizeof(char)); - return r == NULL ? NULL : memcpy(r, string, n); + return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); } @@ -73,7 +73,7 @@ char* strndup(const char* string, size_t maxlen) */ void* memdup(const void* segment, size_t size) { - wchar_t* r = malloc(size * sizeof(wchar_t)); + void* r = malloc(size); return r == NULL ? NULL : memcpy(r, segment, size); } |