diff options
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/acceler.c | 8 | ||||
-rw-r--r-- | Parser/node.c | 11 | ||||
-rw-r--r-- | Parser/parsetok.c | 6 |
3 files changed, 13 insertions, 12 deletions
diff --git a/Parser/acceler.c b/Parser/acceler.c index 6ed12c3..63919c5 100644 --- a/Parser/acceler.c +++ b/Parser/acceler.c @@ -44,7 +44,7 @@ PyGrammar_RemoveAccelerators(grammar *g) s = d->d_state; for (j = 0; j < d->d_nstates; j++, s++) { if (s->s_accel) - PyMem_DEL(s->s_accel); + PyObject_FREE(s->s_accel); s->s_accel = NULL; } } @@ -68,7 +68,7 @@ fixstate(grammar *g, state *s) int *accel; int nl = g->g_ll.ll_nlabels; s->s_accept = 0; - accel = PyMem_NEW(int, nl); + accel = (int *) PyObject_MALLOC(nl * sizeof(int)); for (k = 0; k < nl; k++) accel[k] = -1; a = s->s_arc; @@ -124,7 +124,7 @@ fixstate(grammar *g, state *s) k++; if (k < nl) { int i; - s->s_accel = PyMem_NEW(int, nl-k); + s->s_accel = (int *) PyObject_MALLOC((nl-k) * sizeof(int)); if (s->s_accel == NULL) { fprintf(stderr, "no mem to add parser accelerators\n"); exit(1); @@ -134,5 +134,5 @@ fixstate(grammar *g, state *s) for (i = 0; k < nl; i++, k++) s->s_accel[i] = accel[k]; } - PyMem_DEL(accel); + PyObject_FREE(accel); } diff --git a/Parser/node.c b/Parser/node.c index 780c230..75900ce 100644 --- a/Parser/node.c +++ b/Parser/node.c @@ -7,7 +7,7 @@ node * PyNode_New(int type) { - node *n = PyMem_NEW(node, 1); + node *n = (node *) PyObject_MALLOC(1 * sizeof(node)); if (n == NULL) return NULL; n->n_type = type; @@ -92,7 +92,8 @@ PyNode_AddChild(register node *n1, int type, char *str, int lineno) return E_OVERFLOW; if (current_capacity < required_capacity) { n = n1->n_child; - PyMem_RESIZE(n, node, required_capacity); + n = (node *) PyObject_REALLOC(n, + required_capacity * sizeof(node)); if (n == NULL) return E_NOMEM; n1->n_child = n; @@ -116,7 +117,7 @@ PyNode_Free(node *n) { if (n != NULL) { freechildren(n); - PyMem_DEL(n); + PyObject_FREE(n); } } @@ -127,7 +128,7 @@ freechildren(node *n) for (i = NCH(n); --i >= 0; ) freechildren(CHILD(n, i)); if (n->n_child != NULL) - PyMem_DEL(n->n_child); + PyObject_FREE(n->n_child); if (STR(n) != NULL) - PyMem_DEL(STR(n)); + PyObject_FREE(STR(n)); } diff --git a/Parser/parsetok.c b/Parser/parsetok.c index cd3887d..5758fa74 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -133,7 +133,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, else started = 1; len = b - a; /* XXX this may compute NULL - NULL */ - str = PyMem_NEW(char, len + 1); + str = (char *) PyObject_MALLOC(len + 1); if (str == NULL) { fprintf(stderr, "no mem for next token\n"); err_ret->error = E_NOMEM; @@ -157,7 +157,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, PyParser_AddToken(ps, (int)type, str, tok->lineno, &(err_ret->expected))) != E_OK) { if (err_ret->error != E_DONE) - PyMem_DEL(str); + PyObject_FREE(str); break; } } @@ -178,7 +178,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, err_ret->offset = tok->cur - tok->buf; if (tok->buf != NULL) { size_t len = tok->inp - tok->buf; - err_ret->text = PyMem_NEW(char, len + 1); + err_ret->text = (char *) PyObject_MALLOC(len + 1); if (err_ret->text != NULL) { if (len > 0) strncpy(err_ret->text, tok->buf, len); |