diff options
author | Mattias Andrée <maandree@kth.se> | 2018-09-02 15:32:56 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-09-02 15:32:56 +0200 |
commit | 47128b7def4954c4cf544924c94f018d88033374 (patch) | |
tree | c75e6c76c078a095ff691d42a1f0b2d0ea0f0357 /enstrdup.c | |
parent | Add malloc function attribute were appropriate (diff) | |
download | libsimple-47128b7def4954c4cf544924c94f018d88033374.tar.gz libsimple-47128b7def4954c4cf544924c94f018d88033374.tar.bz2 libsimple-47128b7def4954c4cf544924c94f018d88033374.tar.xz |
misc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'enstrdup.c')
-rw-r--r-- | enstrdup.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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")); |