Fix Coverity 180: Don't overallocate. We don't need structs, but pointers.
Also fix a memory leak.
This commit is contained in:
parent
e545ff30a6
commit
a7d329a9b2
|
@ -124,7 +124,7 @@ addnfa(nfagrammar *gr, char *name)
|
||||||
|
|
||||||
nf = newnfa(name);
|
nf = newnfa(name);
|
||||||
gr->gr_nfa = (nfa **)PyObject_REALLOC(gr->gr_nfa,
|
gr->gr_nfa = (nfa **)PyObject_REALLOC(gr->gr_nfa,
|
||||||
sizeof(nfa) * (gr->gr_nnfas + 1));
|
sizeof(nfa*) * (gr->gr_nnfas + 1));
|
||||||
if (gr->gr_nfa == NULL)
|
if (gr->gr_nfa == NULL)
|
||||||
Py_FatalError("out of mem");
|
Py_FatalError("out of mem");
|
||||||
gr->gr_nfa[gr->gr_nnfas++] = nf;
|
gr->gr_nfa[gr->gr_nnfas++] = nf;
|
||||||
|
@ -487,6 +487,7 @@ makedfa(nfagrammar *gr, nfa *nf, dfa *d)
|
||||||
convert(d, xx_nstates, xx_state);
|
convert(d, xx_nstates, xx_state);
|
||||||
|
|
||||||
/* XXX cleanup */
|
/* XXX cleanup */
|
||||||
|
PyObject_FREE(xx_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue