From c6d6b7dbefb62578be64133e36836fc936945555 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 17 Jan 2020 11:58:41 -0700 Subject: [PATCH] Use MEM_CONTEXT_NEW_BEGIN() block instead of memContextNew(). A few places were using just memContextNew(), probably because they did not immediately need to create anything in the new context, but it's better if we use the same pattern everywhere, even if it results in a few extra mem context switches. --- src/common/lock.c | 6 +++++- src/protocol/helper.c | 6 +++++- src/storage/helper.c | 6 +++++- test/src/common/harnessLog.c | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/common/lock.c b/src/common/lock.c index a743c002a..a8677eb2f 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -175,7 +175,11 @@ lockAcquire(const String *lockPath, const String *stanza, LockType lockType, Tim { MEM_CONTEXT_BEGIN(memContextTop()) { - lockMemContext = memContextNew("Lock"); + MEM_CONTEXT_NEW_BEGIN("Lock") + { + lockMemContext = MEM_CONTEXT_NEW(); + } + MEM_CONTEXT_NEW_END(); } MEM_CONTEXT_END(); } diff --git a/src/protocol/helper.c b/src/protocol/helper.c index 5f144a61c..057b8be99 100644 --- a/src/protocol/helper.c +++ b/src/protocol/helper.c @@ -55,7 +55,11 @@ protocolHelperInit(void) // Create a mem context to store protocol objects MEM_CONTEXT_BEGIN(memContextTop()) { - protocolHelper.memContext = memContextNew("ProtocolHelper"); + MEM_CONTEXT_NEW_BEGIN("ProtocolHelper") + { + protocolHelper.memContext = MEM_CONTEXT_NEW(); + } + MEM_CONTEXT_NEW_END(); } MEM_CONTEXT_END(); } diff --git a/src/storage/helper.c b/src/storage/helper.c index 0ef2bc6b5..508413334 100644 --- a/src/storage/helper.c +++ b/src/storage/helper.c @@ -62,7 +62,11 @@ storageHelperInit(void) { MEM_CONTEXT_BEGIN(memContextTop()) { - storageHelper.memContext = memContextNew("storageHelper"); + MEM_CONTEXT_NEW_BEGIN("StorageHelper") + { + storageHelper.memContext = MEM_CONTEXT_NEW(); + } + MEM_CONTEXT_NEW_END(); } MEM_CONTEXT_END(); } diff --git a/test/src/common/harnessLog.c b/test/src/common/harnessLog.c index 1603191e1..240edf5ae 100644 --- a/test/src/common/harnessLog.c +++ b/test/src/common/harnessLog.c @@ -188,7 +188,11 @@ hrnLogReplaceAdd(const char *expression, const char *expressionSub, const char * { MEM_CONTEXT_BEGIN(memContextTop()) { - harnessLog.memContext = memContextNew("harnessLog"); + MEM_CONTEXT_NEW_BEGIN("HarnessLog") + { + harnessLog.memContext = MEM_CONTEXT_NEW(); + } + MEM_CONTEXT_NEW_END(); } MEM_CONTEXT_END(); }