From 9ddda2322780bdab0e5f734cf2c2e169731afb2b Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Wed, 29 Apr 2015 15:45:34 +0200 Subject: [PATCH] repomd: Add cr_repomd_remove_record() --- src/repomd.c | 9 +++++++++ src/repomd.h | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/repomd.c b/src/repomd.c index 31f9d70..392330d 100644 --- a/src/repomd.c +++ b/src/repomd.c @@ -706,6 +706,15 @@ cr_repomd_detach_record(cr_Repomd *repomd, cr_RepomdRecord *rec) repomd->records = g_slist_remove(repomd->records, rec); } +void +cr_repomd_remove_record(cr_Repomd *repomd, const char *type) +{ + cr_RepomdRecord *rec = cr_repomd_get_record(repomd, type); + if (!rec) return; + cr_repomd_detach_record(repomd, rec); + cr_repomd_record_free(rec); +} + cr_RepomdRecord * cr_repomd_get_record(cr_Repomd *repomd, const char *type) { diff --git a/src/repomd.h b/src/repomd.h index 026aa89..1ef9bdf 100644 --- a/src/repomd.h +++ b/src/repomd.h @@ -237,7 +237,7 @@ void cr_repomd_add_content_tag(cr_Repomd *repomd, const char *tag); /** Get repomd record from the repomd object. * @param repomd cr_Repomd object - * @param type Type of the record + * @param type Type of the record ("primary", "primary_db", ..) * @return Pointer to a record of desired type or NULL */ cr_RepomdRecord *cr_repomd_get_record(cr_Repomd *repomd, const char *type); @@ -250,6 +250,12 @@ cr_RepomdRecord *cr_repomd_get_record(cr_Repomd *repomd, const char *type); */ void cr_repomd_detach_record(cr_Repomd *repomd, cr_RepomdRecord *rec); +/** Remove first record of the specified type + * @param repomd cr_Repomd object + * @param type Type of the record ("primary", "primary_db", ..) + */ +void cr_repomd_remove_record(cr_Repomd *repomd, const char *type); + /** Records are stored in order they were added to the repomd. * Because sometimes deterministic output is desirable this function * exists. -- 2.7.4