From a8e27372d477e945febe7de5eccc458980304405 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 8 Sep 2022 12:09:00 +0300 Subject: xstd: move sizeof() into malloc() --- src/xstd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xstd.c b/src/xstd.c index f06f639..309412c 100644 --- a/src/xstd.c +++ b/src/xstd.c @@ -24,10 +24,10 @@ char *xstrcat(const char *first, const char *second, const char *delimiter) { - size_t size = sizeof(char) * (strlen(first) + strlen(second) + 1); + size_t size = strlen(first) + strlen(second) + 1; if(delimiter) - size += sizeof(char) * strlen(delimiter); - char *res = malloc(size); + size += strlen(delimiter); + char *res = malloc(size * sizeof(char)); strcpy(res, first); if(delimiter) strcat(res, delimiter); -- cgit v1.2.3-18-g5258