gh-114569: Use PyMem_* APIs for most non-PyObject uses (#114574)

Fix usage in Modules, Objects, and Parser subdirectories.
This commit is contained in:
Erlend E. Aasland 2024-01-26 11:11:35 +01:00 committed by GitHub
parent d0f7f5c41d
commit dcd28b5c35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 36 additions and 33 deletions

View file

@ -129,7 +129,7 @@ set_fstring_expr(struct tok_state* tok, struct token *token, char c) {
if (hash_detected) {
Py_ssize_t input_length = tok_mode->last_expr_size - tok_mode->last_expr_end;
char *result = (char *)PyObject_Malloc((input_length + 1) * sizeof(char));
char *result = (char *)PyMem_Malloc((input_length + 1) * sizeof(char));
if (!result) {
return -1;
}
@ -154,7 +154,7 @@ set_fstring_expr(struct tok_state* tok, struct token *token, char c) {
result[j] = '\0'; // Null-terminate the result string
res = PyUnicode_DecodeUTF8(result, j, NULL);
PyObject_Free(result);
PyMem_Free(result);
} else {
res = PyUnicode_DecodeUTF8(
tok_mode->last_expr_buffer,