1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Add MEM_CONTEXT_PRIOR() block and update current call sites.

This macro block encapsulates the common pattern of switching to the prior (formerly called old) mem context to return results from a function.

Also rename MEM_CONTEXT_OLD() to memContextPrior().  This violates our convention of macros being in all caps but memContextPrior() will become a function very soon so this will reduce churn.
This commit is contained in:
David Steele
2020-01-17 13:29:49 -07:00
parent b5fa9951e3
commit ec173f12fb
54 changed files with 399 additions and 296 deletions

View File

@ -208,7 +208,7 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
if (outputRequired)
{
// Just move the entire response kv since the output is the largest part if it
kvMove(responseKv, MEM_CONTEXT_OLD());
kvMove(responseKv, memContextPrior());
}
// Else if no output is required then there should not be any
else if (result != NULL)
@ -322,9 +322,11 @@ protocolClientReadLine(ProtocolClient *this)
else if (strPtr(result)[0] != '.')
THROW_FMT(FormatError, "invalid prefix in '%s'", strPtr(result));
memContextSwitch(MEM_CONTEXT_OLD());
result = strSub(result, 1);
memContextSwitch(MEM_CONTEXT_TEMP());
MEM_CONTEXT_PRIOR_BEGIN()
{
result = strSub(result, 1);
}
MEM_CONTEXT_PRIOR_END();
}
MEM_CONTEXT_TEMP_END();