summaryrefslogtreecommitdiffstats
path: root/src/ctx.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-12-20 20:18:35 -0500
committerTavian Barnes <tavianator@tavianator.com>2023-12-20 20:37:44 -0500
commit70092ae5c8f83a99fbc98dc8e2ca2eaab676a5a8 (patch)
tree3c1ff27c143258cdaa4218972b2960ef4653212a /src/ctx.c
parent9c6e4ce18304c395338c7c5b2bac9eb89583a568 (diff)
downloadbfs-70092ae5c8f83a99fbc98dc8e2ca2eaab676a5a8.tar.xz
expr: Arena-allocate expressions
Diffstat (limited to 'src/ctx.c')
-rw-r--r--src/ctx.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ctx.c b/src/ctx.c
index f5dc465..a3c5140 100644
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -22,6 +22,9 @@ struct bfs_ctx *bfs_ctx_new(void) {
return NULL;
}
+ SLIST_INIT(&ctx->expr_list);
+ ARENA_INIT(&ctx->expr_arena, struct bfs_expr);
+
ctx->maxdepth = INT_MAX;
ctx->flags = BFTW_RECOVER;
ctx->strategy = BFTW_BFS;
@@ -202,9 +205,6 @@ int bfs_ctx_free(struct bfs_ctx *ctx) {
CFILE *cout = ctx->cout;
CFILE *cerr = ctx->cerr;
- bfs_expr_free(ctx->exclude);
- bfs_expr_free(ctx->expr);
-
bfs_mtab_free(ctx->mtab);
bfs_groups_free(ctx->groups);
@@ -241,6 +241,11 @@ int bfs_ctx_free(struct bfs_ctx *ctx) {
free_colors(ctx->colors);
+ for_slist (struct bfs_expr, expr, &ctx->expr_list) {
+ bfs_expr_clear(expr);
+ }
+ arena_destroy(&ctx->expr_arena);
+
for (size_t i = 0; i < ctx->npaths; ++i) {
free((char *)ctx->paths[i]);
}