From 3eade6283956a7f822cdb85e5ae15a94002ed3f9 Mon Sep 17 00:00:00 2001 From: Jakub Kucharski Date: Sat, 27 Aug 2016 06:09:04 +0200 Subject: [PATCH 1/2] goo: fix GooString::STR_STATIC_SIZE calculation Before this fix on 64-bit systems 4 bytes were left unsused (because of memory alignment). I've also removed unnecessary MemoryLayout class which used to be used to calculate GooString::STR_STATIC_SIZE, although it had only made it harder. --- goo/GooString.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/goo/GooString.h b/goo/GooString.h index 5ff01ef..a152a98 100644 --- a/goo/GooString.h +++ b/goo/GooString.h @@ -175,14 +175,8 @@ private: // You can tweak the final object size for different time/space tradeoffs. // In libc malloc(), rounding is 16 so it's best to choose a value that // is a multiple of 16. - class MemoryLayout { - char c[sizeof(char*)]; - int i; - char* s; - }; - static const int STR_FINAL_SIZE = 32; - static const int STR_STATIC_SIZE = STR_FINAL_SIZE - sizeof(MemoryLayout) + sizeof(char*); + static const int STR_STATIC_SIZE = STR_FINAL_SIZE - sizeof(int) - sizeof(char*); int roundedSize(int len); -- 2.9.3