xbps_repository_pool_foreach: simplify internals.
This commit is contained in:
parent
f48ab4a686
commit
d8e7ed0a23
@ -72,7 +72,7 @@ xbps_repository_pool_init(struct xbps_handle *xhp)
|
|||||||
char *plist;
|
char *plist;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
if (prop_object_type(xhp->repo_pool) == PROP_TYPE_ARRAY)
|
if (xhp->repo_pool != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
else if (xhp->cfg == NULL)
|
else if (xhp->cfg == NULL)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
@ -233,7 +233,7 @@ xbps_repository_pool_foreach(
|
|||||||
{
|
{
|
||||||
prop_dictionary_t d;
|
prop_dictionary_t d;
|
||||||
struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
struct repository_pool_index *rpi;
|
struct repository_pool_index rpi;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
@ -251,22 +251,15 @@ xbps_repository_pool_foreach(
|
|||||||
}
|
}
|
||||||
/* Iterate over repository pool */
|
/* Iterate over repository pool */
|
||||||
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
|
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
|
||||||
rpi = malloc(sizeof(*rpi));
|
|
||||||
if (rpi == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
d = prop_array_get(xhp->repo_pool, i);
|
d = prop_array_get(xhp->repo_pool, i);
|
||||||
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi->rpi_uri);
|
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.rpi_uri);
|
||||||
rpi->rpi_repo = prop_dictionary_get(d, "index");
|
rpi.rpi_repo = prop_dictionary_get(d, "index");
|
||||||
rpi->rpi_index = i;
|
rpi.rpi_index = i;
|
||||||
|
|
||||||
rv = (*fn)(rpi, arg, &done);
|
rv = (*fn)(&rpi, arg, &done);
|
||||||
if (rv != 0 || done) {
|
if (rv != 0 || done)
|
||||||
free(rpi);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(rpi);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user