repomd: Add cr_repomd_remove_record()
authorTomas Mlcoch <tmlcoch@redhat.com>
Wed, 29 Apr 2015 13:45:34 +0000 (15:45 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Wed, 29 Apr 2015 13:45:34 +0000 (15:45 +0200)
src/repomd.c
src/repomd.h

index 31f9d70..392330d 100644 (file)
@@ -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)
 {
index 026aa89..1ef9bdf 100644 (file)
@@ -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.