You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-01 00:25:06 +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:
@ -330,7 +330,7 @@ pgClientQuery(PgClient *this, const String *query)
|
||||
}
|
||||
TRY_END();
|
||||
|
||||
varLstMove(result, MEM_CONTEXT_OLD());
|
||||
varLstMove(result, memContextPrior());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
@ -565,9 +565,11 @@ pgTablespaceId(unsigned int pgVersion)
|
||||
{
|
||||
String *pgVersionStr = pgVersionToStr(pgVersion);
|
||||
|
||||
memContextSwitch(MEM_CONTEXT_OLD());
|
||||
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion));
|
||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
||||
MEM_CONTEXT_PRIOR_BEGIN()
|
||||
{
|
||||
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion));
|
||||
}
|
||||
MEM_CONTEXT_PRIOR_END();
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
@ -675,7 +677,7 @@ pgLsnRangeToWalSegmentList(
|
||||
strLstAdd(result, strNewFmt("%08X%08X%08X", timeline, startMajor, startMinor));
|
||||
}
|
||||
|
||||
strLstMove(result, MEM_CONTEXT_OLD());
|
||||
strLstMove(result, memContextPrior());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
Reference in New Issue
Block a user