goo/GooString.cc | 4 ++++ goo/GooString.h | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-)
New commits: commit f5c34c63a64ae3a6af9aee2d2710a966b7e2d95c Author: Jakub Kucharski <[email protected]> Date: Sat Aug 27 06:13:55 2016 +0200 goo: check at compile time if GooString has the right size static_assert is a C++ feature introduced in C++0x. GCC already uses this standard by default, so we can make use of it. In case it's compiled without C++ >= 0x support, the #if macro will get rid of it. diff --git a/goo/GooString.cc b/goo/GooString.cc index fa3142d..1c0c634 100644 --- a/goo/GooString.cc +++ b/goo/GooString.cc @@ -200,6 +200,10 @@ GooString::GooString() { s = NULL; length = 0; Set(NULL); + +#if __cplusplus >= 201103L + static_assert(sizeof(GooString) == GooString::STR_FINAL_SIZE, "You should check memory alignment or STR_STATIC_SIZE calculation."); +#endif } GooString::GooString(const char *sA) { commit 3a1a4baacf9672cd1e26a860303ba22f75c2b942 Author: Jakub Kucharski <[email protected]> Date: Sat Aug 27 06:09:04 2016 +0200 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. 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); _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
