| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4104db3 commit 80d4e2a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ PyGrammar_RemoveAccelerators(grammar *g) | |||
| 44 | 44 | s = d->d_state; | |
| 45 | 45 | for (j = 0; j < d->d_nstates; j++, s++) { | |
| 46 | 46 | if (s->s_accel) | |
| 47 | - PyMem_DEL(s->s_accel); | ||
| 47 | + PyObject_FREE(s->s_accel); | ||
| 48 | 48 | s->s_accel = NULL; | |
| 49 | 49 | } | |
| 50 | 50 | } | |
@@ -68,7 +68,7 @@ fixstate(grammar *g, state *s) | |||
| 68 | 68 | int *accel; | |
| 69 | 69 | int nl = g->g_ll.ll_nlabels; | |
| 70 | 70 | s->s_accept = 0; | |
| 71 | - accel = PyMem_NEW(int, nl); | ||
| 71 | + accel = (int *) PyObject_MALLOC(nl * sizeof(int)); | ||
| 72 | 72 | for (k = 0; k < nl; k++) | |
| 73 | 73 | accel[k] = -1; | |
| 74 | 74 | a = s->s_arc; | |
@@ -124,7 +124,7 @@ fixstate(grammar *g, state *s) | |||
| 124 | 124 | k++; | |
| 125 | 125 | if (k < nl) { | |
| 126 | 126 | int i; | |
| 127 | - s->s_accel = PyMem_NEW(int, nl-k); | ||
| 127 | + s->s_accel = (int *) PyObject_MALLOC((nl-k) * sizeof(int)); | ||
| 128 | 128 | if (s->s_accel == NULL) { | |
| 129 | 129 | fprintf(stderr, "no mem to add parser accelerators\n"); | |
| 130 | 130 | exit(1); | |
@@ -134,5 +134,5 @@ fixstate(grammar *g, state *s) | |||
| 134 | 134 | for (i = 0; k < nl; i++, k++) | |
| 135 | 135 | s->s_accel[i] = accel[k]; | |
| 136 | 136 | } | |
| 137 | - PyMem_DEL(accel); | ||
| 137 | + PyObject_FREE(accel); | ||
| 138 | 138 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | node * | |
| 8 | 8 | PyNode_New(int type) | |
| 9 | 9 | { | |
| 10 | - node *n = PyMem_NEW(node, 1); | ||
| 10 | + node *n = (node *) PyObject_MALLOC(1 * sizeof(node)); | ||
| 11 | 11 | if (n == NULL) | |
| 12 | 12 | return NULL; | |
| 13 | 13 | n->n_type = type; | |
@@ -92,7 +92,8 @@ PyNode_AddChild(register node *n1, int type, char *str, int lineno) | |||
| 92 | 92 | return E_OVERFLOW; | |
| 93 | 93 | if (current_capacity < required_capacity) { | |
| 94 | 94 | n = n1->n_child; | |
| 95 | - PyMem_RESIZE(n, node, required_capacity); | ||
| 95 | + n = (node *) PyObject_REALLOC(n, | ||
| 96 | + required_capacity * sizeof(node)); | ||
| 96 | 97 | if (n == NULL) | |
| 97 | 98 | return E_NOMEM; | |
| 98 | 99 | n1->n_child = n; | |
@@ -116,7 +117,7 @@ PyNode_Free(node *n) | |||
| 116 | 117 | { | |
| 117 | 118 | if (n != NULL) { | |
| 118 | 119 | freechildren(n); | |
| 119 | - PyMem_DEL(n); | ||
| 120 | + PyObject_FREE(n); | ||
| 120 | 121 | } | |
| 121 | 122 | } | |
| 122 | 123 | ||
@@ -127,7 +128,7 @@ freechildren(node *n) | |||
| 127 | 128 | for (i = NCH(n); --i >= 0; ) | |
| 128 | 129 | freechildren(CHILD(n, i)); | |
| 129 | 130 | if (n->n_child != NULL) | |
| 130 | - PyMem_DEL(n->n_child); | ||
| 131 | + PyObject_FREE(n->n_child); | ||
| 131 | 132 | if (STR(n) != NULL) | |
| 132 | - PyMem_DEL(STR(n)); | ||
| 133 | + PyObject_FREE(STR(n)); | ||
| 133 | 134 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,7 +133,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, | |||
| 133 | 133 | else | |
| 134 | 134 | started = 1; | |
| 135 | 135 | len = b - a; /* XXX this may compute NULL - NULL */ | |
| 136 | - str = PyMem_NEW(char, len + 1); | ||
| 136 | + str = (char *) PyObject_MALLOC(len + 1); | ||
| 137 | 137 | if (str == NULL) { | |
| 138 | 138 | fprintf(stderr, "no mem for next token\n"); | |
| 139 | 139 | err_ret->error = E_NOMEM; | |
@@ -157,7 +157,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, | |||
| 157 | 157 | PyParser_AddToken(ps, (int)type, str, tok->lineno, | |
| 158 | 158 | &(err_ret->expected))) != E_OK) { | |
| 159 | 159 | if (err_ret->error != E_DONE) | |
| 160 | - PyMem_DEL(str); | ||
| 160 | + PyObject_FREE(str); | ||
| 161 | 161 | break; | |
| 162 | 162 | } | |
| 163 | 163 | } | |
@@ -178,7 +178,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, | |||
| 178 | 178 | err_ret->offset = tok->cur - tok->buf; | |
| 179 | 179 | if (tok->buf != NULL) { | |
| 180 | 180 | size_t len = tok->inp - tok->buf; | |
| 181 | - err_ret->text = PyMem_NEW(char, len + 1); | ||
| 181 | + err_ret->text = (char *) PyObject_MALLOC(len + 1); | ||
| 182 | 182 | if (err_ret->text != NULL) { | |
| 183 | 183 | if (len > 0) | |
| 184 | 184 | strncpy(err_ret->text, tok->buf, len); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -719,7 +719,7 @@ com_free(struct compiling *c) | |||
| 719 | 719 | Py_XDECREF(c->c_cellvars); | |
| 720 | 720 | Py_XDECREF(c->c_lnotab); | |
| 721 | 721 | if (c->c_future) | |
| 722 | - PyMem_Free((void *)c->c_future); | ||
| 722 | + PyObject_FREE((void *)c->c_future); | ||
| 723 | 723 | } | |
| 724 | 724 | ||
| 725 | 725 | static void | |
@@ -2020,15 +2020,15 @@ com_factor(struct compiling *c, node *n) | |||
| 2020 | 2020 | return; | |
| 2021 | 2021 | } | |
| 2022 | 2022 | if (childtype == MINUS) { | |
| 2023 | - char *s = PyMem_Malloc(strlen(STR(pnum)) + 2); | ||
| 2023 | + char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2); | ||
| 2024 | 2024 | if (s == NULL) { | |
| 2025 | 2025 | com_error(c, PyExc_MemoryError, ""); | |
| 2026 | 2026 | com_addbyte(c, 255); | |
| 2027 | 2027 | return; | |
| 2028 | 2028 | } | |
| 2029 | 2029 | s[0] = '-'; | |
| 2030 | 2030 | strcpy(s + 1, STR(pnum)); | |
| 2031 | - PyMem_Free(STR(pnum)); | ||
| 2031 | + PyObject_FREE(STR(pnum)); | ||
| 2032 | 2032 | STR(pnum) = s; | |
| 2033 | 2033 | } | |
| 2034 | 2034 | com_atom(c, patom); | |
@@ -4116,7 +4116,7 @@ PyNode_CompileSymtable(node *n, char *filename) | |||
| 4116 | 4116 | ||
| 4117 | 4117 | st = symtable_init(); | |
| 4118 | 4118 | if (st == NULL) { | |
| 4119 | - PyMem_Free((void *)ff); | ||
| 4119 | + PyObject_FREE((void *)ff); | ||
| 4120 | 4120 | return NULL; | |
| 4121 | 4121 | } | |
| 4122 | 4122 | st->st_future = ff; | |
@@ -4129,7 +4129,7 @@ PyNode_CompileSymtable(node *n, char *filename) | |||
| 4129 | 4129 | ||
| 4130 | 4130 | return st; | |
| 4131 | 4131 | fail: | |
| 4132 | - PyMem_Free((void *)ff); | ||
| 4132 | + PyObject_FREE((void *)ff); | ||
| 4133 | 4133 | st->st_future = NULL; | |
| 4134 | 4134 | PySymtable_Free(st); | |
| 4135 | 4135 | return NULL; | |
@@ -4722,7 +4722,7 @@ symtable_init() | |||
| 4722 | 4722 | { | |
| 4723 | 4723 | struct symtable *st; | |
| 4724 | 4724 | ||
| 4725 | - st = (struct symtable *)PyMem_Malloc(sizeof(struct symtable)); | ||
| 4725 | + st = (struct symtable *)PyObject_MALLOC(sizeof(struct symtable)); | ||
| 4726 | 4726 | if (st == NULL) | |
| 4727 | 4727 | return NULL; | |
| 4728 | 4728 | st->st_pass = 1; | |
@@ -4749,7 +4749,7 @@ PySymtable_Free(struct symtable *st) | |||
| 4749 | 4749 | Py_XDECREF(st->st_symbols); | |
| 4750 | 4750 | Py_XDECREF(st->st_stack); | |
| 4751 | 4751 | Py_XDECREF(st->st_cur); | |
| 4752 | - PyMem_Free((void *)st); | ||
| 4752 | + PyObject_FREE((void *)st); | ||
| 4753 | 4753 | } | |
| 4754 | 4754 | ||
| 4755 | 4755 | /* When the compiler exits a scope, it must should update the scope's | |
| Back | FazBrowse Home | New Git URL |
0 commit comments