summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-03-01 18:16:06 +0100
committerMichael Schroeder <mls@suse.de>2012-03-01 18:16:06 +0100
commit0a5baff771db11cea25e646677e72765e164e57a (patch)
tree3aa81601b23882eb21d13626edefe9a7df9e2079
parent03c154a682036cbfee22bc62e21cef2a2fe74649 (diff)
downloadlibsolv-0a5baff771db11cea25e646677e72765e164e57a.tar.gz
libsolv-0a5baff771db11cea25e646677e72765e164e57a.tar.bz2
libsolv-0a5baff771db11cea25e646677e72765e164e57a.zip
- change last argument in repo_write from Id ** to Queue *. Hopefully nobody uses that arg...
-rw-r--r--src/repo_write.c25
-rw-r--r--src/repo_write.h3
-rw-r--r--tools/common_write.c16
3 files changed, 18 insertions, 26 deletions
diff --git a/src/repo_write.c b/src/repo_write.c
index 1e679b8..7675f44 100644
--- a/src/repo_write.c
+++ b/src/repo_write.c
@@ -975,7 +975,7 @@ repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata)
* 5) write everything to disk
*/
int
-repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Id **keyarrayp)
+repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Queue *keyq)
{
Pool *pool = repo->pool;
int i, j, n;
@@ -1250,14 +1250,11 @@ for (i = 1; i < target.nkeys; i++)
#endif
/* copy keys if requested */
- if (keyarrayp)
+ if (keyq)
{
- *keyarrayp = solv_calloc(2 * target.nkeys + 1, sizeof(Id));
+ queue_empty(keyq);
for (i = 1; i < target.nkeys; i++)
- {
- (*keyarrayp)[2 * i - 2] = target.keys[i].name;
- (*keyarrayp)[2 * i - 1] = target.keys[i].type;
- }
+ queue_push2(keyq, target.keys[i].name, target.keys[i].type);
}
if (poolusage > 1)
@@ -1453,21 +1450,17 @@ for (i = 1; i < target.nkeys; i++)
if (i != n)
{
target.keys[n] = target.keys[i];
- if (keyarrayp)
+ if (keyq)
{
- (*keyarrayp)[2 * n - 2] = (*keyarrayp)[2 * i - 2];
- (*keyarrayp)[2 * n - 1] = (*keyarrayp)[2 * i - 1];
+ keyq->elements[2 * n - 2] = keyq->elements[2 * i - 2];
+ keyq->elements[2 * n - 1] = keyq->elements[2 * i - 1];
}
}
n++;
}
target.nkeys = n;
- if (keyarrayp)
- {
- /* terminate array */
- (*keyarrayp)[2 * n - 2] = 0;
- (*keyarrayp)[2 * n - 1] = 0;
- }
+ if (keyq)
+ queue_truncate(keyq, 2 * n - 2);
/* update schema data to the new key ids */
for (i = 1; i < target.schemadatalen; i++)
diff --git a/src/repo_write.h b/src/repo_write.h
index 9f93f05..756a41e 100644
--- a/src/repo_write.h
+++ b/src/repo_write.h
@@ -16,8 +16,9 @@
#include <stdio.h>
#include "repo.h"
+#include "queue.h"
-extern int repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Id **keyarrayp);
+extern int repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Queue *keyq);
extern int repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata);
extern int repodata_write(Repodata *data , FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata);
diff --git a/tools/common_write.c b/tools/common_write.c
index 608ae96..9f7e627 100644
--- a/tools/common_write.c
+++ b/tools/common_write.c
@@ -176,17 +176,15 @@ keyfilter_other(Repo *repo, Repokey *key, void *kfdata)
static void
write_info(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Repodata *info, const char *location)
{
- Id h, *keyarray = 0;
- int i;
+ Id h;
+ Queue keyq;
- repo_write(repo, fp, keyfilter, kfdata, &keyarray);
+ queue_init(&keyq);
+ repo_write(repo, fp, keyfilter, kfdata, &keyq);
h = repodata_new_handle(info);
- if (keyarray)
- {
- for (i = 0; keyarray[i]; i++)
- repodata_add_idarray(info, h, REPOSITORY_KEYS, keyarray[i]);
- }
- solv_free(keyarray);
+ if (keyq.count)
+ repodata_set_idarray(info, h, REPOSITORY_KEYS, &keyq);
+ queue_free(&keyq);
repodata_set_str(info, h, REPOSITORY_LOCATION, location);
repodata_add_flexarray(info, SOLVID_META, REPOSITORY_EXTERNAL, h);
}