Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In closure_free(), use the FSM allocator instead of free(). #489

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fsm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ main(int argc, char *argv[])
printf("\n");
}

closure_free(closures, fsm->statecount);
closure_free(fsm, closures, fsm->statecount);

return 0;
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/libfsm/closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>

#include <fsm/alloc.h>
#include <fsm/fsm.h>
#include <fsm/pred.h>
#include <fsm/walk.h>
Expand Down Expand Up @@ -189,14 +190,14 @@ epsilon_closure(struct fsm *fsm)
}

void
closure_free(struct state_set **closures, size_t n)
closure_free(struct fsm *fsm, struct state_set **closures, size_t n)
{
fsm_state_t s;

for (s = 0; s < n; s++) {
state_set_free(closures[s]);
}

free(closures);
f_free(fsm->alloc, closures);
}

2 changes: 1 addition & 1 deletion src/libfsm/epsilons.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fsm_remove_epsilons(struct fsm *nfa)
res = 1;
cleanup:
if (eclosures != NULL) {
closure_free(eclosures, state_count);
closure_free(nfa, eclosures, state_count);
}

return res;
Expand Down
2 changes: 1 addition & 1 deletion src/libfsm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct state_set **
epsilon_closure(struct fsm *fsm);

void
closure_free(struct state_set **closures, size_t n);
closure_free(struct fsm *fsm, struct state_set **closures, size_t n);

/*
* Internal free function that invokes free(3) by default, or a user-provided
Expand Down
Loading