Skip to content

Commit

Permalink
Merge pull request #489 from sw17ch/sw17ch/fix-closure-free-alloc
Browse files Browse the repository at this point in the history
In `closure_free()`, use the FSM allocator instead of `free()`.
  • Loading branch information
katef authored Aug 23, 2024
2 parents 64f26cc + 5fa91fe commit 98fe88b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
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

0 comments on commit 98fe88b

Please sign in to comment.