From 1c9a42dd825c2125abbc819eabfdbfa544c70cb4 Mon Sep 17 00:00:00 2001 From: "Cindy Wang (CindyLinz)" Date: Sat, 17 May 2014 13:01:33 +0800 Subject: [PATCH] my_strdup / my_strndup malloc smaller --- src/str.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/str.c b/src/str.c index 02087dd..1709625 100644 --- a/src/str.c +++ b/src/str.c @@ -187,7 +187,7 @@ char *my_strdup(const char *s) { while( s[count] ) ++count; ++count; - out = malloc(sizeof(char*) * count); + out = malloc(sizeof(char) * count); out[--count] = 0; while( --count >= 0 ) out[count] = s[count]; @@ -200,7 +200,7 @@ char *my_strndup(const char *s, int n) { while( count < n && s[count] ) ++count; ++count; - out = malloc(sizeof(char*) * count); + out = malloc(sizeof(char) * count); out[--count] = 0; while( --count >= 0 ) out[count] = s[count];