From 47128b7def4954c4cf544924c94f018d88033374 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 2 Sep 2018 15:32:56 +0200 Subject: misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- enstrdup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'enstrdup.c') diff --git a/enstrdup.c b/enstrdup.c index 4ad78d4..f330422 100644 --- a/enstrdup.c +++ b/enstrdup.c @@ -6,9 +6,11 @@ char * libsimple_enstrdup(int status, const char *s) { - char *ret = strdup(s); + size_t n = strlen(s) + 1; + char *ret = aligned_alloc(1, n); if (!ret) enprintf(status, "strdup:"); + memcpy(ret, s, n); return ret; } @@ -26,6 +28,7 @@ main(void) if (have_custom_malloc()) { assert((info = get_allocinfo(s))); assert(info->size == 6); + assert(info->alignment == 1); assert(!info->zeroed); } assert(!strcmp(s, "hello")); @@ -35,6 +38,7 @@ main(void) if (have_custom_malloc()) { assert((info = get_allocinfo(s))); assert(info->size == 5); + assert(info->alignment == 1); assert(!info->zeroed); } assert(!strcmp(s, "test")); -- cgit v1.2.3-70-g09d2