diff --git a/src/info/infoArchive.c b/src/info/infoArchive.c index 1b2309889..8ad3c4ad1 100644 --- a/src/info/infoArchive.c +++ b/src/info/infoArchive.c @@ -35,6 +35,7 @@ struct InfoArchive InfoPg *infoPg; // Contents of the DB data }; +OBJECT_DEFINE_MOVE(INFO_ARCHIVE); OBJECT_DEFINE_FREE(INFO_ARCHIVE); /*********************************************************************************************************************************** diff --git a/src/info/infoArchive.h b/src/info/infoArchive.h index a2b7ef83a..93331dc4f 100644 --- a/src/info/infoArchive.h +++ b/src/info/infoArchive.h @@ -43,6 +43,9 @@ Functions const String *infoArchiveIdHistoryMatch( const InfoArchive *this, const unsigned int historyId, const unsigned int pgVersion, const uint64_t pgSystemId); +// Move to a new parent mem context +InfoArchive *infoArchiveMove(InfoArchive *this, MemContext *parentNew); + /*********************************************************************************************************************************** Getters/Setters ***********************************************************************************************************************************/ diff --git a/src/info/infoBackup.c b/src/info/infoBackup.c index 5884d5abb..764424d95 100644 --- a/src/info/infoBackup.c +++ b/src/info/infoBackup.c @@ -64,6 +64,7 @@ struct InfoBackup List *backup; // List of current backups and their associated data }; +OBJECT_DEFINE_MOVE(INFO_BACKUP); OBJECT_DEFINE_FREE(INFO_BACKUP); /*********************************************************************************************************************************** diff --git a/src/info/infoBackup.h b/src/info/infoBackup.h index fe4a6b809..eedc47ac1 100644 --- a/src/info/infoBackup.h +++ b/src/info/infoBackup.h @@ -74,6 +74,9 @@ void infoBackupDataAdd(const InfoBackup *this, const Manifest *manifest); // Delete backup from the current backup list void infoBackupDataDelete(const InfoBackup *this, const String *backupDeleteLabel); +// Move to a new parent mem context +InfoBackup *infoBackupMove(InfoBackup *this, MemContext *parentNew); + /*********************************************************************************************************************************** Getters/Setters ***********************************************************************************************************************************/ diff --git a/test/src/module/info/infoArchiveTest.c b/test/src/module/info/infoArchiveTest.c index 724a9df07..324f7f964 100644 --- a/test/src/module/info/infoArchiveTest.c +++ b/test/src/module/info/infoArchiveTest.c @@ -35,7 +35,14 @@ testRun(void) InfoArchive *info = NULL; - TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), " load new archive info"); + // Load and test move function + MEM_CONTEXT_TEMP_BEGIN() + { + TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), "load new archive info"); + TEST_RESULT_VOID(infoArchiveMove(info, memContextPrior()), " move info"); + } + MEM_CONTEXT_TEMP_END(); + TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", " archiveId set"); TEST_RESULT_PTR(infoArchivePg(info), info->infoPg, " infoPg set"); TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, " no cipher sub"); diff --git a/test/src/module/info/infoBackupTest.c b/test/src/module/info/infoBackupTest.c index 6337e4ce7..4c1891458 100644 --- a/test/src/module/info/infoBackupTest.c +++ b/test/src/module/info/infoBackupTest.c @@ -40,9 +40,15 @@ testRun(void) "\"db-version\":\"9.4\"}\n" ); - // Load to make sure ignore-section is ignored - InfoBackup *infoBackup; - TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentLoad)), " new backup info"); + InfoBackup *infoBackup = NULL; + + // Load and test move function then make sure ignore-section is ignored + MEM_CONTEXT_TEMP_BEGIN() + { + TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentLoad)), "new backup info"); + TEST_RESULT_VOID(infoBackupMove(infoBackup, memContextPrior()), " move info"); + } + MEM_CONTEXT_TEMP_END(); // Save to verify with new created info backup Buffer *contentSave = bufNew(0);