ref: 9da098b32fcd51d33eedada0ff9efc796aafb92a
parent: 304a0473edc6714ef98a199eeffcf137651461d4
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Jan 12 19:24:18 EST 2025
mk_symbol: force alignment on some 32-bit systems that have it as 4 bytes instead of 8
--- a/flisp.c
+++ b/flisp.c
@@ -197,9 +197,16 @@
mk_symbol(const char *str, int len, bool copy)
{
symbol_t *sym;
+ int sz = sizeof(*sym) + (copy ? len+1 : 0);
+#ifdef BITS64
+ sym = MEM_ALLOC(sz);
+#else
+ sym = MEM_ALLOC(sz+7);
+ if((uintptr_t)sym & 7)
+ sym = (symbol_t*)(((uintptr_t)sym + 7U) & ~7U);
+#endif
+ assert(((uintptr_t)sym & 7) == 0);
- sym = MEM_ALLOC(sizeof(*sym) + (copy ? len+1 : 0));
- assert(((uintptr_t)sym & 0x7) == 0); // make sure malloc aligns 8
sym->numtype = NONNUMERIC;
if(fl_is_keyword_name(str, len)){
value_t s = tagptr(sym, TAG_SYM);