commit:     0ef80b6c9643010ca3c4908f0a7a5c9bfb2d5769
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 10 21:01:04 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 10 21:01:04 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0ef80b6c

libq/array: migrate all code to new API

drop legacy macros, adapt code to use new APIs where possible.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/array.h | 11 ---------
 libq/dep.c   |  2 +-
 libq/set.c   |  4 ++--
 libq/tree.c  |  4 ++--
 main.c       | 16 ++++++-------
 q.c          | 12 +++++-----
 qcheck.c     | 21 ++++++++---------
 qdepends.c   |  2 +-
 qkeyword.c   |  6 ++---
 qlist.c      |  2 +-
 qlop.c       | 74 ++++++++++++++++++++++++++----------------------------------
 qmanifest.c  |  4 ++--
 qpkg.c       |  4 ++--
 qsize.c      | 10 ++++----
 qwhich.c     | 14 +++++-------
 15 files changed, 80 insertions(+), 106 deletions(-)

diff --git a/libq/array.h b/libq/array.h
index 7268019..84f7812 100644
--- a/libq/array.h
+++ b/libq/array.h
@@ -12,17 +12,6 @@
 
 #include <string.h>  /* strlen in push_str */
 
-#define xarrayget(A,I) array_get(A,I)
-#define xarraypush_ptr(A,E) array_append(A,E)
-#define xarraypush(A,E,L) array_append_copy(A,E,L)
-#define xarraypush_str(A,S) array_append_copy(A,S,strlen(S)+1/*NUL*/)
-#define xarraysort(A,C) array_sort(A,C)
-#define xarraydelete_ptr(A,E) array_remove(A,E)
-#define xarraydelete(A,E) array_delete(A,E,NULL)
-#define xarrayfree_int(A) array_free(A)
-#define xarrayfree(A) array_deepfree(A,NULL)
-
-/* new 2026 interface to array */
 typedef struct array_t array;
 typedef void (array_free_cb)(void *priv);
 

diff --git a/libq/dep.c b/libq/dep.c
index fd9a284..712ace3 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -381,7 +381,7 @@ dep_flatten_tree(dep_node *root, array *out)
 {
        if (root->type != DEP_NULL) {
                if (root->type == DEP_NORM) {
-                       xarraypush_ptr(out, atom_clone(root->atom));
+                       array_append(out, atom_clone(root->atom));
                }
                if (root->children)
                        dep_flatten_tree(root->children, out);

diff --git a/libq/set.c b/libq/set.c
index e198503..a612839 100644
--- a/libq/set.c
+++ b/libq/set.c
@@ -296,7 +296,7 @@ array_set(set *q, array *ret)
 
        for (i = 0; i < _SET_HASH_SIZE; i++) {
                for (w = q->buckets[i]; w != NULL; w = w->next)
-                       xarraypush_ptr(ret, w->name);
+                       array_append(ret, w->name);
        }
 
        return q->len;
@@ -314,7 +314,7 @@ values_set(set *q, array *ret)
 
        for (i = 0; i < _SET_HASH_SIZE; i++) {
                for (w = q->buckets[i]; w != NULL; w = w->next)
-                       xarraypush_ptr(ret, w->val);
+                       array_append(ret, w->val);
        }
 
        return q->len;

diff --git a/libq/tree.c b/libq/tree.c
index 5d6ba9d..37d0d36 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -263,7 +263,7 @@ tree_close(tree_ctx *ctx)
                        tree_close_cat(cat);
                }
 
-               xarrayfree_int(t);
+               array_free(t);
        }
        if (ctx->cache.store != NULL)
                free(ctx->cache.store);
@@ -2316,7 +2316,7 @@ tree_foreach_pkg_int
                                          sizeof(*cat_ctx->pkg_ctxs), 
tree_pkg_compar);
                        }
                }
-               xarrayfree_int(cats);
+               array_free(cats);
 
                /* do the final run this call was supposed to be for using the
                 * (sorted) cache, the callback can be empty for tree_match_atom

diff --git a/main.c b/main.c
index 78d550d..d2a10f4 100644
--- a/main.c
+++ b/main.c
@@ -764,7 +764,7 @@ read_portage_profile(const char *profile, env_vars vars[], 
set *masks)
                                        /* match the repo */
                                        repo_name = NULL;
                                        array_for_each(overlays, n, overlay) {
-                                               repo_name = 
xarrayget(overlay_names, n);
+                                               repo_name = 
array_get(overlay_names, n);
                                                if (strcmp(repo_name, s) == 0) {
                                                        snprintf(profile_file, 
sizeof(profile_file),
                                                                        
"%s/profiles/%s/", overlay, p);
@@ -1171,9 +1171,9 @@ initialize_portage_env(void)
 
                        if (overlay == NULL) {  /* add PORTDIR to overlays */
                                overlay = xstrdup(main_overlay);
-                               xarraypush_ptr(overlays, (char *)overlay);
-                               xarraypush_str(overlay_names, "<PORTDIR>");
-                               xarraypush_str(overlay_src, var->src);
+                               array_append(overlays, (char *)overlay);
+                               array_append_strcpy(overlay_names, "<PORTDIR>");
+                               array_append_strcpy(overlay_src, var->src);
                        } else {
                                /* ignore make.conf and/or env setting origin 
if defined by
                                 * repos.conf since the former are deprecated */
@@ -1233,7 +1233,7 @@ initialize_portage_env(void)
                                                fprintf(stderr, "%s ", val);
                                        }
                                        fprintf(stderr, "\n");
-                                       xarrayfree_int(vals);
+                                       array_free(vals);
                                }       break;
                        }
                }
@@ -1342,9 +1342,9 @@ int main(int argc, char **argv)
        optind = 0;
        i = q_main(argc, argv);
 
-       xarrayfree(overlays);
-       xarrayfree(overlay_names);
-       xarrayfree(overlay_src);
+       array_deepfree(overlays, NULL);
+       array_deepfree(overlay_names, NULL);
+       array_deepfree(overlay_src, NULL);
 
        if (warnout != stderr)
                fclose(warnout);

diff --git a/q.c b/q.c
index 2fd57a5..692b4ec 100644
--- a/q.c
+++ b/q.c
@@ -579,7 +579,7 @@ int q_main(int argc, char **argv)
                size_t n;
 
                array_for_each(overlays, n, overlay) {
-                       repo_name = xarrayget(overlay_names, n);
+                       repo_name = array_get(overlay_names, n);
                        if (strcmp(repo_name, "<PORTDIR>") == 0) {
                                repo_name = NULL;
                                snprintf(buf, sizeof(buf), 
"%s/profiles/repo_name", overlay);
@@ -595,7 +595,7 @@ int q_main(int argc, char **argv)
                                        NORM, overlay,
                                        YELLOW, main_overlay == overlay ? " 
(main)" : "", NORM);
                        if (verbose)
-                               printf(" [%s]\n", (char 
*)xarrayget(overlay_src, n));
+                               printf(" [%s]\n", (char 
*)array_get(overlay_src, n));
                        else
                                printf("\n");
                        if (repo_name_len != 0) {
@@ -642,7 +642,7 @@ int q_main(int argc, char **argv)
                                                array_for_each(vals, n, val) {
                                                        printf("%s%s", n == 0 ? 
"" : " ", val);
                                                }
-                                               xarrayfree_int(vals);
+                                               array_free(vals);
                                                printf("\"%s", NORM);
                                        }       break;
                                }
@@ -678,7 +678,7 @@ int q_main(int argc, char **argv)
                                                array_for_each(vals, n, val) {
                                                        printf("%s%s", n == 0 ? 
RED : " ", val);
                                                }
-                                               xarrayfree_int(vals);
+                                               array_free(vals);
                                                printf("%s", NORM);
                                        }       break;
                                }
@@ -789,8 +789,8 @@ int q_main(int argc, char **argv)
                if (buf != NULL)
                        free(buf);
 
-               xarrayfree_int(masks);
-               xarrayfree_int(files);
+               array_free(masks);
+               array_free(files);
 
                return 0;
        }

diff --git a/qcheck.c b/qcheck.c
index 9ca2ed9..34a18bd 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -450,7 +450,7 @@ int qcheck_main(int argc, char **argv)
                case 's': {
                        regex_t preg;
                        xregcomp(&preg, optarg, REG_EXTENDED | REG_NOSUB);
-                       xarraypush(state.regex_arr, &preg, sizeof(preg));
+                       array_append_copy(state.regex_arr, &preg, sizeof(preg));
                        break;
                }
                case 'u': state.qc_update = true;                    break;
@@ -474,7 +474,7 @@ int qcheck_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
                else
-                       xarraypush_ptr(state.atoms, atom);
+                       array_append(state.atoms, atom);
        }
 
        vdb = tree_open_vdb(portroot, portvdb);
@@ -490,14 +490,13 @@ int qcheck_main(int argc, char **argv)
                }
                tree_close(vdb);
        }
-       if (array_cnt(state.regex_arr) > 0) {
-               void *preg;
-               array_for_each(state.regex_arr, i, preg)
-                       regfree(preg);
-       }
-       xarrayfree(state.regex_arr);
-       array_for_each(state.atoms, i, atom)
-               atom_implode(atom);
-       xarrayfree_int(state.atoms);
+
+    if (array_cnt(state.regex_arr) > 0) {
+        void *preg;
+        array_for_each(state.regex_arr, i, preg)
+            regfree(preg);
+    }
+       array_deepfree(state.regex_arr, NULL);
+       array_deepfree(state.atoms, (array_free_cb *)atom_implode);
        return ret != 0;
 }

diff --git a/qdepends.c b/qdepends.c
index 3d36c98..1e8d58a 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -402,7 +402,7 @@ int qdepends_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
                else
-                       xarraypush_ptr(state.atoms, atom);
+                       array_append(state.atoms, atom);
        }
 
        if (state.qmode & QMODE_INSTALLED || verbose)

diff --git a/qkeyword.c b/qkeyword.c
index 76bc7cc..84727bd 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -913,12 +913,12 @@ int qkeyword_main(int argc, char **argv)
                        if ((atom = atom_explode(mask)) == NULL)
                                continue;
                        bucket = array_new();
-                       xarraypush_ptr(bucket, atom);
+                       array_append(bucket, atom);
                        pmasks = add_set_value(atom_format("%[CAT]%[PN]", atom),
                                                                   bucket, 
(void **)&ebuck, pmasks);
                        if (ebuck != NULL) {
-                               xarraypush_ptr(ebuck, atom);
-                               xarrayfree_int(bucket);
+                               array_append(ebuck, atom);
+                               array_free(bucket);
                        }
                }
        }

diff --git a/qlist.c b/qlist.c
index d63c810..d887abc 100644
--- a/qlist.c
+++ b/qlist.c
@@ -268,7 +268,7 @@ qlist_match(
                                break;
                }
 
-               xarrayfree_int(masks);
+               array_free(masks);
 
                if (match)
                        return false;

diff --git a/qlop.c b/qlop.c
index b1eb074..7daae34 100644
--- a/qlop.c
+++ b/qlop.c
@@ -521,9 +521,7 @@ static int do_emerge_log(
                                        array *vals = array_new();
 
                                        values_set(atomset, vals);
-                                       array_for_each(vals, i, atomw)
-                                               atom_implode(atomw);
-                                       xarrayfree_int(vals);
+                                       array_deepfree(vals, (array_free_cb 
*)atomw);
 
                                        clear_set(atomset);
                                        last_merge = tstart_emerge;
@@ -797,7 +795,7 @@ static int do_emerge_log(
                                pkg->tbegin = tstart;
                                pkg->time = (time_t)0;
                                pkg->cnt = 0;
-                               xarraypush_ptr(merge_matches, pkg);
+                               array_append(merge_matches, pkg);
                        } else {  /* ::: completed */
                                array_for_each_rev(merge_matches, i, pkgw) {
                                        if (strcmp(p + 16, pkgw->id) != 0)
@@ -830,14 +828,14 @@ static int do_emerge_log(
                                                        if (elapsed > 
pkg->tbegin)
                                                                pkg->tbegin = 
elapsed;
                                                        
atom_implode(pkgw->atom);
-                                                       
xarraydelete(merge_matches, i);
+                                                       
array_delete(merge_matches, i, NULL);
                                                } else {
                                                        /* new entry */
                                                        pkgw->id[0] = '\0';
                                                        pkgw->cnt = 1;
                                                        pkgw->time = elapsed;
                                                        pkgw->tbegin = elapsed;
-                                                       
xarraydelete_ptr(merge_matches, i);
+                                                       
array_remove(merge_matches, i);
                                                }
                                                break;
                                        }
@@ -886,7 +884,7 @@ static int do_emerge_log(
                                                                
atom_format(flags->fmt, pkgw->atom));
                                        }
                                        atom_implode(pkgw->atom);
-                                       xarraydelete(merge_matches, i);
+                                       array_delete(merge_matches, i, NULL);
                                        break;
                                }
                        }
@@ -944,7 +942,7 @@ static int do_emerge_log(
                                pkg->tbegin = tstart;
                                pkg->time = (time_t)0;
                                pkg->cnt = 0;
-                               xarraypush_ptr(unmerge_matches, pkg);
+                               array_append(unmerge_matches, pkg);
                        } else {
                                array_for_each_rev(unmerge_matches, i, pkgw) {
                                        if (strcmp(p + 23, pkgw->id) != 0)
@@ -977,14 +975,14 @@ static int do_emerge_log(
                                                        if (elapsed > 
pkg->tbegin)
                                                                pkg->tbegin = 
elapsed;
                                                        
atom_implode(pkgw->atom);
-                                                       
xarraydelete(unmerge_matches, i);
+                                                       
array_delete(unmerge_matches, i, NULL);
                                                } else {
                                                        /* new entry */
                                                        pkgw->id[0] = '\0';
                                                        pkgw->cnt = 1;
                                                        pkgw->time = elapsed;
                                                        pkgw->tbegin = elapsed;
-                                                       
xarraydelete_ptr(unmerge_matches, i);
+                                                       
array_remove(unmerge_matches, i);
                                                }
                                                break;
                                        }
@@ -1021,7 +1019,7 @@ static int do_emerge_log(
                                                                
atom_format(flags->fmt, pkgw->atom));
                                        }
                                        atom_implode(pkgw->atom);
-                                       xarraydelete(unmerge_matches, i);
+                                       array_delete(unmerge_matches, i, NULL);
                                        break;
                                }
                        }
@@ -1180,7 +1178,7 @@ static int do_emerge_log(
                array *avgs = array_new();
 
                values_set(merge_averages, avgs);
-               xarraysort(avgs, pkg_sort_cb);
+               array_sort(avgs, pkg_sort_cb);
                array_for_each(avgs, i, pkg) {
                        printf("%s: %s average for %s%zd%s merge%s\n",
                                        atom_format(flags->fmt, pkg->atom),
@@ -1189,11 +1187,11 @@ static int do_emerge_log(
                        total_merges += pkg->cnt;
                        total_time += pkg->time;
                }
-               xarrayfree_int(avgs);
+               array_free(avgs);
 
                avgs = array_new();
                values_set(unmerge_averages, avgs);
-               xarraysort(avgs, pkg_sort_cb);
+               array_sort(avgs, pkg_sort_cb);
                array_for_each(avgs, i, pkg) {
                        printf("%s: %s average for %s%zd%s unmerge%s\n",
                                        atom_format(flags->fmt, pkg->atom),
@@ -1202,7 +1200,7 @@ static int do_emerge_log(
                        total_unmerges += pkg->cnt;
                        total_time += pkg->time;
                }
-               xarrayfree_int(avgs);
+               array_free(avgs);
 
                if (sync_cnt > 0) {
                        printf("%ssync%s: %s average for %s%zd%s sync%s\n",
@@ -1236,8 +1234,8 @@ static int do_emerge_log(
                char found;
 
                values_set(merge_averages, avgs);
-               xarraysort(avgs, pkg_sort_cb);
-               xarraysort(atoms, atom_compar_cb);
+               array_sort(avgs, pkg_sort_cb);
+               array_sort(atoms, atom_compar_cb);
 
                /* each atom has its own matches in here, but since it's all
                 * sorted, we basically can go around here jumping from CAT-PN
@@ -1338,7 +1336,7 @@ static int do_emerge_log(
                                }
                        }
                }
-               xarrayfree_int(avgs);
+               array_free(avgs);
        }
 
        {
@@ -1349,34 +1347,28 @@ static int do_emerge_log(
                        atom_implode(pkgw->atom);
                        free(pkgw);
                }
-               xarrayfree_int(t);
+               array_free(t);
                t = array_new();
                values_set(unmerge_averages, t);
                array_for_each(t, i, pkgw) {
                        atom_implode(pkgw->atom);
                        free(pkgw);
                }
-               xarrayfree_int(t);
+               array_free(t);
        }
        free_set(merge_averages);
        free_set(unmerge_averages);
-       array_for_each_rev(merge_matches, i, pkgw) {
+       array_for_each_rev(merge_matches, i, pkgw)
                atom_implode(pkgw->atom);
-               xarraydelete(merge_matches, i);
-       }
-       xarrayfree(merge_matches);
-       array_for_each_rev(unmerge_matches, i, pkgw) {
+       array_deepfree(merge_matches, NULL);
+       array_for_each_rev(unmerge_matches, i, pkgw)
                atom_implode(pkgw->atom);
-               xarraydelete(unmerge_matches, i);
-       }
-       xarrayfree(unmerge_matches);
+       array_deepfree(unmerge_matches, NULL);
        if (atomset != NULL) {
                array *t = array_new();
 
                values_set(atomset, t);
-               array_for_each(t, i, atom)
-                       atom_implode(atom);
-               xarrayfree_int(t);
+               array_deepfree(t, (array_free_cb *)atom_implode);
                free_set(atomset);
        }
        return 0;
@@ -1444,7 +1436,7 @@ static array *probe_proc(array *atoms)
                                                if (atom->CATEGORY == NULL || 
atom->P == NULL) {
                                                        atom_implode(atom);
                                                } else {
-                                                       
xarraypush_ptr(ret_atoms, atom);
+                                                       array_append(ret_atoms, 
atom);
                                                        continue;
                                                }
                                        }
@@ -1517,7 +1509,7 @@ static array *probe_proc(array *atoms)
                                                continue;
                                        }
 
-                                       xarraypush_ptr(ret_atoms, atom);
+                                       array_append(ret_atoms, atom);
                                }
                                scandir_free(links, linkslen);
                        }
@@ -1549,14 +1541,14 @@ static array *probe_proc(array *atoms)
                array_for_each(atoms, i, atom) {
                        array_for_each(ret_atoms, j, atomr) {
                                if (atom_compare(atomr, atom) != EQUAL) {
-                                       xarraydelete_ptr(ret_atoms, j);
+                                       array_remove(ret_atoms, j);
                                        atom_implode(atomr);
                                        break;
                                }
                        }
                        atom_implode(atom);
                }
-               xarrayfree_int(atoms);
+               array_free(atoms);
        }
 
        /* ret_atoms is allocated on the stack, so copy into atoms which is
@@ -1567,10 +1559,10 @@ static array *probe_proc(array *atoms)
                atom->PV = NULL;
                atom->PVR = NULL;
                atom->PR_int = 0;
-               xarraypush_ptr(atoms, atom);
+               array_append(atoms, atom);
        }
 
-       xarrayfree_int(ret_atoms);
+       array_free(ret_atoms);
 
        return atoms;
 }
@@ -1666,7 +1658,7 @@ int qlop_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
                else
-                       xarraypush_ptr(atoms, atom);
+                       array_append(atoms, atom);
        }
        for (p = atomfile; p != NULL && *p != '\0'; p = q) {
                while (isspace((int)(*p)))
@@ -1680,7 +1672,7 @@ int qlop_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", p);
                else
-                       xarraypush_ptr(atoms, atom);
+                       array_append(atoms, atom);
        }
        if (atomfile)
                free(atomfile);
@@ -1813,9 +1805,7 @@ int qlop_main(int argc, char **argv)
        if (start_time < LONG_MAX)
                do_emerge_log(logfile, &m, atoms, start_time, end_time);
 
-       array_for_each(atoms, i, atom)
-               atom_implode(atom);
-       xarrayfree_int(atoms);
+       array_deepfree(atoms, (array_free_cb *)atom_implode);
        free(logfile);
 
        return EXIT_SUCCESS;

diff --git a/qmanifest.c b/qmanifest.c
index e018d35..be9cdbb 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1769,7 +1769,7 @@ qmanifest_main(int argc, char **argv)
                size_t repolen;
 
                array_for_each(overlays, n, overlay) {
-                       repo = xarrayget(overlay_names, n);
+                       repo = array_get(overlay_names, n);
                        if (strcmp(repo, "<PORTDIR>") == 0) {
                                repo = NULL;
                                repolen = 0;
@@ -1803,7 +1803,7 @@ qmanifest_main(int argc, char **argv)
        for (i = 0; i < argc; i++) {
                array_for_each(overlay_names, n, overlay) {
                        if (strcmp(overlay, argv[i]) == 0) {
-                               overlay = xarrayget(overlays, n);
+                               overlay = array_get(overlays, n);
                                break;
                        }
                        overlay = NULL;

diff --git a/qpkg.c b/qpkg.c
index 51cb3bc..ab12edd 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -115,7 +115,7 @@ qpkg_clean(qpkg_cb_args *args)
                 * that the remainder is what we would clean */
                array_for_each_rev(bins, n, binatomstr) {
                        if (contains_set(binatomstr, known_pkgs))
-                               xarraydelete_ptr(bins, n);
+                               array_remove(bins, n);
                }
 
                free_set(known_pkgs);
@@ -144,7 +144,7 @@ qpkg_clean(qpkg_cb_args *args)
                atom_implode(atom);
        }
 
-       xarrayfree_int(bins);
+       array_free(bins);
        free_set(bin_pkgs);
 
        disp_units = KILOBYTE;

diff --git a/qsize.c b/qsize.c
index b154d4b..02bd752 100644
--- a/qsize.c
+++ b/qsize.c
@@ -225,7 +225,7 @@ int qsize_main(int argc, char **argv)
                case 'i': {
                        regex_t regex;
                        xregcomp(&regex, optarg, REG_EXTENDED|REG_NOSUB);
-                       xarraypush(state.ignore_regexp, &regex, sizeof(regex));
+                       array_append_copy(state.ignore_regexp, &regex, 
sizeof(regex));
                        break;
                }
                }
@@ -238,7 +238,7 @@ int qsize_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
                else
-                       xarraypush_ptr(state.atoms, atom);
+                       array_append(state.atoms, atom);
        }
 
        if (state.fmt == NULL) {
@@ -285,10 +285,8 @@ int qsize_main(int argc, char **argv)
                           state.disp_units ? state.str_disp_units : "");
        }
 
-       array_for_each(state.atoms, i, atom)
-               atom_implode(atom);
-       xarrayfree_int(state.atoms);
-       xarrayfree(state.ignore_regexp);
+       array_deepfree(state.atoms, (array_free_cb *)atom_implode);
+       array_deepfree(state.ignore_regexp, NULL);
        free_set(state.uniq_files);
 
        return ret;

diff --git a/qwhich.c b/qwhich.c
index 7cf691d..bf6d3f2 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -139,26 +139,26 @@ int qwhich_main(int argc, char **argv)
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
                else
-                       xarraypush_ptr(atoms, atom);
+                       array_append(atoms, atom);
        }
 
        /* TODO: silence when the path doesn't exist -- reasonable though? */
        if (m.do_vdb) {
                t = tree_open_vdb(portroot, portvdb);
                if (t != NULL)
-                       xarraypush_ptr(trees, t);
+                       array_append(trees, t);
        }
        if (m.do_binpkg) {
                t = tree_open_binpkg("/", pkgdir);
                if (t != NULL)
-                       xarraypush_ptr(trees, t);
+                       array_append(trees, t);
        }
 
        if (m.do_tree) {
                array_for_each(overlays, n, overlay) {
                        t = tree_open(portroot, overlay);
                        if (t != NULL)
-                               xarraypush_ptr(trees, t);
+                               array_append(trees, t);
                }
        }
 
@@ -247,10 +247,8 @@ int qwhich_main(int argc, char **argv)
                }
                tree_close(t);
        }
-       array_for_each(atoms, i, atom)
-               atom_implode(atom);
-       xarrayfree_int(atoms);
-       xarrayfree_int(trees);
+       array_deepfree(atoms, (array_free_cb *)atom_implode);
+       array_free(trees);
 
        return EXIT_SUCCESS;
 }

Reply via email to