diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-06-27 17:47:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 17:47:00 (GMT) |
commit | 6dcbc2422de9e2a7ff89a4689572d84001e230b2 (patch) | |
tree | af130f63db00b49618e3ca4017a12ded4e28f766 /Parser | |
parent | 9cfcdb7d6e4d09bde63bc7116b2ab0d96724527e (diff) | |
download | cpython-6dcbc2422de9e2a7ff89a4689572d84001e230b2.zip cpython-6dcbc2422de9e2a7ff89a4689572d84001e230b2.tar.gz cpython-6dcbc2422de9e2a7ff89a4689572d84001e230b2.tar.bz2 |
bpo-41132: Use pymalloc allocator in the f-string parser (GH-21173)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen.c | 6 | ||||
-rw-r--r-- | Parser/string_parser.c | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index 79fcd2f..b4216fa 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -395,7 +395,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, const char *fstring_msg = "f-string: "; Py_ssize_t len = strlen(fstring_msg) + strlen(errmsg); - char *new_errmsg = PyMem_RawMalloc(len + 1); // Lengths of both strings plus NULL character + char *new_errmsg = PyMem_Malloc(len + 1); // Lengths of both strings plus NULL character if (!new_errmsg) { return (void *) PyErr_NoMemory(); } @@ -443,7 +443,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, Py_DECREF(errstr); Py_DECREF(value); if (p->start_rule == Py_fstring_input) { - PyMem_RawFree((void *)errmsg); + PyMem_Free((void *)errmsg); } return NULL; @@ -451,7 +451,7 @@ error: Py_XDECREF(errstr); Py_XDECREF(error_line); if (p->start_rule == Py_fstring_input) { - PyMem_RawFree((void *)errmsg); + PyMem_Free((void *)errmsg); } return NULL; } diff --git a/Parser/string_parser.c b/Parser/string_parser.c index f8e2427..ed7ca7f 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -592,7 +592,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; @@ -605,7 +605,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); @@ -631,7 +631,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; @@ -1143,7 +1143,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; } @@ -1153,9 +1153,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; } @@ -1183,7 +1183,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; |