You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-05 04:30:41 +03: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:
@@ -361,10 +361,12 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
|
||||
strPtr(walSegment), strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")));
|
||||
}
|
||||
|
||||
// Copy file name of WAL segment found into the calling context
|
||||
memContextSwitch(MEM_CONTEXT_OLD());
|
||||
result = strDup(strLstGet(list, 0));
|
||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
||||
// Copy file name of WAL segment found into the prior context
|
||||
MEM_CONTEXT_PRIOR_BEGIN()
|
||||
{
|
||||
result = strDup(strLstGet(list, 0));
|
||||
}
|
||||
MEM_CONTEXT_PRIOR_END();
|
||||
}
|
||||
}
|
||||
while (result == NULL && wait != NULL && waitMore(wait));
|
||||
@@ -469,7 +471,7 @@ walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned i
|
||||
}
|
||||
}
|
||||
|
||||
strLstMove(result, MEM_CONTEXT_OLD());
|
||||
strLstMove(result, memContextPrior());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user