diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-24 23:08:18 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-24 23:08:18 +0200 |
commit | f39efad8df5327babb6b6141a03ce06e49b4cbdf (patch) | |
tree | 7acd0ba1a9c101e65e259a04d4c3073f814f5532 | |
parent | c2f1874f38e48e1efb67d3efc9c436a6bf5b1a8a (diff) | |
download | fastd-f39efad8df5327babb6b6141a03ce06e49b4cbdf.tar fastd-f39efad8df5327babb6b6141a03ce06e49b4cbdf.zip |
String stack buffer sizes must be aligned because of optimized strlen builtins.
-rw-r--r-- | src/fastd.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fastd.h b/src/fastd.h index d015484..e16cbb8 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -419,7 +419,7 @@ static inline size_t fastd_max_packet_size(const fastd_context_t *ctx) { } static inline fastd_string_stack_t* fastd_string_stack_dup(const char *str) { - fastd_string_stack_t *ret = malloc(sizeof(fastd_string_stack_t) + strlen(str) + 1); + fastd_string_stack_t *ret = malloc(alignto(sizeof(fastd_string_stack_t) + strlen(str) + 1, 8)); ret->next = NULL; strcpy(ret->str, str); @@ -428,7 +428,7 @@ static inline fastd_string_stack_t* fastd_string_stack_dup(const char *str) { static inline fastd_string_stack_t* fastd_string_stack_dupn(const char *str, size_t len) { size_t str_len = strnlen(str, len); - fastd_string_stack_t *ret = malloc(sizeof(fastd_string_stack_t) + str_len + 1); + fastd_string_stack_t *ret = malloc(alignto(sizeof(fastd_string_stack_t) + str_len + 1, 8)); ret->next = NULL; strncpy(ret->str, str, str_len); ret->str[str_len] = 0; @@ -437,7 +437,7 @@ static inline fastd_string_stack_t* fastd_string_stack_dupn(const char *str, siz } static inline fastd_string_stack_t* fastd_string_stack_push(fastd_string_stack_t *stack, const char *str) { - fastd_string_stack_t *ret = malloc(sizeof(fastd_string_stack_t) + strlen(str) + 1); + fastd_string_stack_t *ret = malloc(alignto(sizeof(fastd_string_stack_t) + strlen(str) + 1, 8)); ret->next = stack; strcpy(ret->str, str); |