summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
Diffstat (limited to 'Include')
-rw-r--r--Include/objimpl.h6
-rw-r--r--Include/pymem.h32
2 files changed, 12 insertions, 26 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index af53717..464b1bf 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -102,7 +102,7 @@ PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyObject_Free(void *ptr);
-/* Macros */
+// Deprecated aliases only kept for backward compatibility.
#define PyObject_MALLOC PyObject_Malloc
#define PyObject_REALLOC PyObject_Realloc
#define PyObject_FREE PyObject_Free
@@ -138,8 +138,8 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
#define PyObject_NewVar(type, typeobj, n) \
( (type *) _PyObject_NewVar((typeobj), (n)) )
-// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
-// PyObject_MALLOC() with _PyObject_VAR_SIZE().
+// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
+// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
diff --git a/Include/pymem.h b/Include/pymem.h
index 607feb9..5b9dd42 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -53,18 +53,6 @@ PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);
-/* Macros. */
-
-/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
- for malloc(0), which would be treated as an error. Some platforms
- would return a pointer with no memory behind it, which would break
- pymalloc. To solve these problems, allocate an extra byte. */
-/* Returns NULL to indicate error if a negative size or size larger than
- Py_ssize_t can represent is supplied. Helps prevents security holes. */
-#define PyMem_MALLOC(n) PyMem_Malloc(n)
-#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
-#define PyMem_FREE(p) PyMem_Free(p)
-
/*
* Type-oriented memory interface
* ==============================
@@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_New(type, n) \
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
-#define PyMem_NEW(type, n) \
- ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
- ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
/*
* The value of (p) is always clobbered by this macro regardless of success.
@@ -91,15 +76,16 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_Resize(p, type, n) \
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
-#define PyMem_RESIZE(p, type, n) \
- ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
- (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
-/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
- * anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
- */
-#define PyMem_Del PyMem_Free
-#define PyMem_DEL PyMem_FREE
+
+// Deprecated aliases only kept for backward compatibility.
+#define PyMem_MALLOC(n) PyMem_Malloc(n)
+#define PyMem_NEW(type, n) PyMem_New(type, n)
+#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
+#define PyMem_RESIZE(p, type, n) PyMem_Resize(p, type, n)
+#define PyMem_FREE(p) PyMem_Free(p)
+#define PyMem_Del(p) PyMem_Free(p)
+#define PyMem_DEL(p) PyMem_Free(p)
#ifndef Py_LIMITED_API