#include <config.h>
#include <errno.h>
+#include <stdalign.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h> /* For CHAR_BIT. */
"cookie" after each allocated string data block, and check for the
presence of this cookie during GC. */
-#define GC_STRING_OVERRUN_COOKIE_SIZE 4
+#define GC_STRING_OVERRUN_COOKIE_SIZE 8
static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
- { '\xde', '\xad', '\xbe', '\xef' };
+ { '\xde', '\xad', '\xbe', '\xef', '\xde', '\xad', '\xbe', '\xef' };
#else
#define GC_STRING_OVERRUN_COOKIE_SIZE 0
#define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE)
+/* Make sure that allocating the extra bytes doesn't misalign
+ `sdata'. */
+
+verify (GC_STRING_EXTRA % alignof (sdata) == 0);
+
/* Exact bound on the number of bytes in a string, not counting the
terminating NUL. A string cannot contain more bytes than
STRING_BYTES_BOUND, nor can it be so long that the size_t
data->string = s;
b->next_free = (sdata *) ((char *) data + needed + GC_STRING_EXTRA);
+ eassert ((uintptr_t) (char *) b->next_free % alignof (sdata) == 0);
MALLOC_UNBLOCK_INPUT;