From 25ee913932a9de1ca2a57d0b7c37309504af8a1f Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 20 Aug 2020 15:53:01 -0400 Subject: [PATCH] Rearrange members in StackTraceData struct to save memory. This arrangement is more efficient on 64-bit systems due to alignment. There is no difference on 32-bit systems. --- src/common/stackTrace.c | 4 ++-- test/src/module/common/stackTraceTest.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/stackTrace.c b/src/common/stackTrace.c index 6135c529d..ebeaa17f6 100644 --- a/src/common/stackTrace.c +++ b/src/common/stackTrace.c @@ -34,10 +34,10 @@ typedef struct StackTraceData LogLevel functionLogLevel; unsigned int tryDepth; - char *param; - size_t paramSize; bool paramOverflow; bool paramLog; + char *param; + size_t paramSize; } StackTraceData; static StackTraceData stackTrace[STACK_TRACE_MAX]; diff --git a/test/src/module/common/stackTraceTest.c b/test/src/module/common/stackTraceTest.c index 24022e1fa..9fb908d81 100644 --- a/test/src/module/common/stackTraceTest.c +++ b/test/src/module/common/stackTraceTest.c @@ -68,6 +68,10 @@ testRun(void) #ifdef WITH_BACKTRACE stackTraceInit(testExe()); #endif + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("check size of StackTraceData"); + + TEST_RESULT_UINT(sizeof(StackTraceData), TEST_64BIT() ? 48 : 32, "check"); TEST_ERROR(stackTracePop("file1", "function1", false), AssertError, "assertion 'stackSize > 0' failed");