1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Safely initialize manifest object.

Using a designated initializer is safer than zeroing the struct.  It is also better for debugging because Valgrind should be able to detect access to areas that are not initialized due to alignment.
This commit is contained in:
David Steele 2019-11-21 12:09:24 -05:00
parent 270f9496e4
commit 53cd530bbf

View File

@ -366,18 +366,19 @@ manifestNewInternal(void)
{
FUNCTION_TEST_VOID();
// Create object
Manifest *this = memNew(sizeof(Manifest));
this->memContext = memContextCurrent();
Manifest *this = memNewRaw(sizeof(Manifest));
// Create lists
this->dbList = lstNewP(sizeof(ManifestDb), .comparator = lstComparatorStr);
this->fileList = lstNewP(sizeof(ManifestFile), .comparator = lstComparatorStr);
this->linkList = lstNewP(sizeof(ManifestLink), .comparator = lstComparatorStr);
this->pathList = lstNewP(sizeof(ManifestPath), .comparator = lstComparatorStr);
this->ownerList = strLstNew();
this->referenceList = strLstNew();
this->targetList = lstNewP(sizeof(ManifestTarget), .comparator = lstComparatorStr);
*this = (Manifest)
{
.memContext = memContextCurrent(),
.dbList = lstNewP(sizeof(ManifestDb), .comparator = lstComparatorStr),
.fileList = lstNewP(sizeof(ManifestFile), .comparator = lstComparatorStr),
.linkList = lstNewP(sizeof(ManifestLink), .comparator = lstComparatorStr),
.pathList = lstNewP(sizeof(ManifestPath), .comparator = lstComparatorStr),
.ownerList = strLstNew(),
.referenceList = strLstNew(),
.targetList = lstNewP(sizeof(ManifestTarget), .comparator = lstComparatorStr),
};
FUNCTION_TEST_RETURN(this);
}