aboutsummaryrefslogtreecommitdiffstats
path: root/src/string
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-09-01 15:57:03 +0200
committerMattias Andrée <maandree@kth.se>2018-09-01 15:57:03 +0200
commit8647f020c35bd91904cb67d65168c5b5f2521098 (patch)
tree9cf5abcffc8cfff304672026b1095be9f3febafe /src/string
parentmemcmp: compare unsigned chars (diff)
downloadslibc-8647f020c35bd91904cb67d65168c5b5f2521098.tar.gz
slibc-8647f020c35bd91904cb67d65168c5b5f2521098.tar.bz2
slibc-8647f020c35bd91904cb67d65168c5b5f2521098.tar.xz
m + strdup and strndup: use aligned_alloc(1, n) instead of malloc(n)
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/string/str/strdup.c2
-rw-r--r--src/string/strn/strndup.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/string/str/strdup.c b/src/string/str/strdup.c
index 6670ee9..9b428b4 100644
--- a/src/string/str/strdup.c
+++ b/src/string/str/strdup.c
@@ -34,7 +34,7 @@
char* strdup(const char* string)
{
size_t n = strlen(string) + 1;
- char* r = malloc(n * sizeof(char));
+ char* r = aligned_alloc(1, n * sizeof(char));
return r == NULL ? NULL : memcpy(r, string, n * sizeof(char));
}
diff --git a/src/string/strn/strndup.c b/src/string/strn/strndup.c
index 7d6e565..5dc17e0 100644
--- a/src/string/strn/strndup.c
+++ b/src/string/strn/strndup.c
@@ -39,7 +39,7 @@
char* strndup(const char* string, size_t maxlen)
{
size_t n = strnlen(string, maxlen) + 1;
- char* r = malloc(n * sizeof(char));
+ char* r = aligned_alloc(1, n * sizeof(char));
return r == NULL ? NULL : memcpy(r, string, n * sizeof(char));
}