summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-06-27 18:35:18 (GMT)
committerGitHub <noreply@github.com>2020-06-27 18:35:18 (GMT)
commit5193d0a665eb0944faae9fb20e2062cea0dc02e7 (patch)
treebc84aa36929e9545888bf3e0e0a48e2a6823787b /Parser
parent9191eacf9e1a4eabfadaf993779c428de7a0b2b3 (diff)
downloadcpython-5193d0a665eb0944faae9fb20e2062cea0dc02e7.zip
cpython-5193d0a665eb0944faae9fb20e2062cea0dc02e7.tar.gz
cpython-5193d0a665eb0944faae9fb20e2062cea0dc02e7.tar.bz2
[3.9] bpo-41132: Use pymalloc allocator in the f-string parser (GH-21173) (GH-21183)
(cherry picked from commit 6dcbc2422de9e2a7ff89a4689572d84001e230b2) Automerge-Triggered-By: @pablogsal
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/parse_string.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c
index a367ba7..61e6044 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/pegen/parse_string.c
@@ -597,7 +597,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
len = expr_end - expr_start;
/* Allocate 3 extra bytes: open paren, close paren, null byte. */
- str = PyMem_RawMalloc(len + 3);
+ str = PyMem_Malloc(len + 3);
if (str == NULL) {
PyErr_NoMemory();
return NULL;
@@ -610,7 +610,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
struct tok_state* tok = PyTokenizer_FromString(str, 1);
if (tok == NULL) {
- PyMem_RawFree(str);
+ PyMem_Free(str);
return NULL;
}
Py_INCREF(p->tok->filename);
@@ -636,7 +636,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
result = expr;
exit:
- PyMem_RawFree(str);
+ PyMem_Free(str);
_PyPegen_Parser_Free(p2);
PyTokenizer_Free(tok);
return result;
@@ -1148,7 +1148,7 @@ ExprList_Append(ExprList *l, expr_ty exp)
Py_ssize_t i;
/* We're still using the cached data. Switch to
alloc-ing. */
- l->p = PyMem_RawMalloc(sizeof(expr_ty) * new_size);
+ l->p = PyMem_Malloc(sizeof(expr_ty) * new_size);
if (!l->p) {
return -1;
}
@@ -1158,9 +1158,9 @@ ExprList_Append(ExprList *l, expr_ty exp)
}
} else {
/* Just realloc. */
- expr_ty *tmp = PyMem_RawRealloc(l->p, sizeof(expr_ty) * new_size);
+ expr_ty *tmp = PyMem_Realloc(l->p, sizeof(expr_ty) * new_size);
if (!tmp) {
- PyMem_RawFree(l->p);
+ PyMem_Free(l->p);
l->p = NULL;
return -1;
}
@@ -1188,7 +1188,7 @@ ExprList_Dealloc(ExprList *l)
/* Do nothing. */
} else {
/* We have dynamically allocated. Free the memory. */
- PyMem_RawFree(l->p);
+ PyMem_Free(l->p);
}
l->p = NULL;
l->size = -1;