aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_nfa.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-04-12 11:37:22 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-04-13 08:22:44 -0300
commit34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b (patch)
tree3342c6d4a1cc54bbadb6018725410117885b3517 /src/nvim/regexp_nfa.c
parentba10e311bddab18e38b1b706e232f804c2da9174 (diff)
downloadrneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.gz
rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.bz2
rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.zip
memory: Add `free` wrapper and refactor project to use it
We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r--src/nvim/regexp_nfa.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 1de167c40f..56e488fbd4 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -2886,7 +2886,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
if (stackp < stack) \
{ \
st_error(postfix, end, p); \
- free(stack); \
+ xfree(stack); \
return NULL; \
}
@@ -3317,13 +3317,13 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
e = POP();
if (stackp != stack) {
- free(stack);
+ xfree(stack);
EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA),"
"too many states left on stack"));
}
if (istate >= nstate) {
- free(stack);
+ xfree(stack);
EMSG_RET_NULL(_("E876: (NFA regexp) "
"Not enough space to store the whole NFA "));
}
@@ -3337,7 +3337,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
ret = e.start;
theend:
- free(stack);
+ xfree(stack);
return ret;
#undef POP1
@@ -4195,7 +4195,7 @@ addstate_here (
memmove(&(newl[listidx + count]),
&(l->t[listidx + 1]),
sizeof(nfa_thread_T) * (l->n - count - listidx - 1));
- free(l->t);
+ xfree(l->t);
l->t = newl;
} else {
/* make space for new states, then move them from the
@@ -6033,9 +6033,9 @@ nextchar:
theend:
/* Free memory */
- free(list[0].t);
- free(list[1].t);
- free(listids);
+ xfree(list[0].t);
+ xfree(list[1].t);
+ xfree(listids);
#undef ADD_STATE_IF_MATCH
#ifdef NFA_REGEXP_DEBUG_LOG
fclose(debug);
@@ -6340,13 +6340,13 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags)
nfa_regengine.expr = NULL;
out:
- free(post_start);
+ xfree(post_start);
post_start = post_ptr = post_end = NULL;
state_ptr = NULL;
return (regprog_T *)prog;
fail:
- free(prog);
+ xfree(prog);
prog = NULL;
#ifdef REGEXP_DEBUG
nfa_postfix_dump(expr, FAIL);
@@ -6361,9 +6361,9 @@ fail:
static void nfa_regfree(regprog_T *prog)
{
if (prog != NULL) {
- free(((nfa_regprog_T *)prog)->match_text);
- free(((nfa_regprog_T *)prog)->pattern);
- free(prog);
+ xfree(((nfa_regprog_T *)prog)->match_text);
+ xfree(((nfa_regprog_T *)prog)->pattern);
+ xfree(prog);
}
}