From 4cbf3e2ff9dd975acce6da37a2a174694660caf5 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 22 Jun 2017 21:42:03 -0400 Subject: [PATCH] introduced member query macro to do a better 32 bit fix --- 4cpp/4cpp_lexer.h | 8 ++++++-- 4tech_defines.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/4cpp/4cpp_lexer.h b/4cpp/4cpp_lexer.h index f98bcebf..5d3c80eb 100644 --- a/4cpp/4cpp_lexer.h +++ b/4cpp/4cpp_lexer.h @@ -43,6 +43,10 @@ typedef int32_t b32_4tech; # define Assert(n) do{ if (!(n)) *(int*)0 = 0xA11E; }while(0) #endif +#if !defined(Member) +# define Member(T, m) (((T*)0)->m) +#endif + #if !defined(API_EXPORT) # define API_EXPORT #endif @@ -78,7 +82,7 @@ DOC_RETURN(Returns the memory size, in bytes, needed to allocate a table for the memsize += 8 + (len+3)&(~3); } u32_4tech table_count = (str_count * 3) / 2; - memsize += table_count*sizeof(u64_4tech); + memsize += table_count*sizeof(*Member(Cpp_Keyword_Table, keywords)); return(memsize); } @@ -97,7 +101,7 @@ DOC_RETURN(Returns the memory size, in bytes, needed to allocate a table for the memsize += 8 + (len+3)&(~3); } u32_4tech table_count = (str_count * 3)/2; - memsize += table_count*sizeof(u64_4tech); + memsize += table_count*sizeof(*Member(Cpp_Keyword_Table, keywords)); return(memsize); } diff --git a/4tech_defines.h b/4tech_defines.h index c0f9ced3..648c6ad6 100644 --- a/4tech_defines.h +++ b/4tech_defines.h @@ -46,6 +46,7 @@ typedef double f64; #define ArrayCount(a) ((sizeof(a))/(sizeof(*a))) #define ExpandArray(a) (a), (ArrayCount(a)) #define AllowLocal(c) (void)(c) +#define Member(T, m) (((T*)0)->m) #if defined(Assert) # undef Assert