} cr_CbData;
static int
-pkgcb(cr_Package *pkg, void *cbdata, GError **err)
+primary_newpkgcb(cr_Package **pkg,
+ const char *pkgId,
+ const char *name,
+ const char *arch,
+ void *cbdata,
+ GError **err)
+{
+ cr_CbData *cb_data = cbdata;
+
+ CR_UNUSED(name);
+ CR_UNUSED(arch);
+ CR_UNUSED(err);
+
+ assert(*pkg == NULL);
+
+ if (cb_data->chunk) {
+ *pkg = cr_package_new_without_chunk();
+ (*pkg)->chunk = cb_data->chunk;
+ } else {
+ *pkg = cr_package_new();
+ }
+
+ return CR_CB_RET_OK;
+}
+
+static int
+primary_pkgcb(cr_Package *pkg, void *cbdata, GError **err)
{
gboolean store_pkg = TRUE;
cr_CbData *cb_data = cbdata;
NULL, NULL);
}
- // TODO: Remove pointer to shared string chunk
+ if (cb_data->chunk) {
+ assert(pkg->chunk == cb_data->chunk);
+ pkg->chunk = NULL;
+ }
if (!store_pkg) {
cr_package_free(pkg);
*pkg = g_hash_table_lookup(cb_data->ht, pkgId);
+ if (cb_data->chunk) {
+ assert(!(*pkg)->chunk);
+ (*pkg)->chunk = cb_data->chunk;
+ }
+
+ return CR_CB_RET_OK;
+}
+
+static int
+pkgcb(cr_Package *pkg, void *cbdata, GError **err)
+{
+ cr_CbData *cb_data = cbdata;
+
+ CR_UNUSED(err);
+
+ if (cb_data->chunk) {
+ assert(pkg->chunk == cb_data->chunk);
+ pkg->chunk = NULL;
+ }
+
return CR_CB_RET_OK;
}
cb_data.pkglist_ht = pkglist_ht;
cr_xml_parse_primary(primary_xml_path,
- NULL,
- NULL,
- pkgcb,
+ primary_newpkgcb,
+ &cb_data,
+ primary_pkgcb,
&cb_data,
NULL,
NULL,
cr_xml_parse_filelists(filelists_xml_path,
newpkgcb,
&cb_data,
- NULL,
- NULL,
+ pkgcb,
+ &cb_data,
NULL,
NULL,
&tmp_err);
cr_xml_parse_other(other_xml_path,
newpkgcb,
&cb_data,
- NULL,
- NULL,
+ pkgcb,
+ &cb_data,
NULL,
NULL,
&tmp_err);