Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Parser/pegen/parse_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -4765,7 +4765,7 @@ fstring_compile_expr(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;
Expand All @@ -4781,15 +4781,15 @@ fstring_compile_expr(const char *expr_start, const char *expr_end,
mod_n = PyParser_SimpleParseStringFlagsFilename(str, "<fstring>",
Py_eval_input, 0);
if (!mod_n) {
PyMem_RawFree(str);
PyMem_Free(str);
return NULL;
}
/* Reuse str to find the correct column offset. */
str[0] = '{';
str[len+1] = '}';
fstring_fix_node_location(n, mod_n, str);
mod = PyAST_FromNode(mod_n, &cf, "<fstring>", c->c_arena);
PyMem_RawFree(str);
PyMem_Free(str);
PyNode_Free(mod_n);
if (!mod)
return NULL;
Expand Down Expand Up @@ -5305,17 +5305,17 @@ 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;
/* Copy the cached data into the new buffer. */
for (i = 0; i < l->size; i++)
l->p[i] = l->data[i];
} 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;
}
Expand Down Expand Up @@ -5343,7 +5343,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;
Expand Down