@@ -53,18 +53,6 @@ PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
5353PyAPI_FUNC (void * ) PyMem_Realloc (void * ptr , size_t new_size );
5454PyAPI_FUNC (void ) PyMem_Free (void * ptr );
5555
56- /* Macros. */
57-
58- /* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
59- for malloc(0), which would be treated as an error. Some platforms
60- would return a pointer with no memory behind it, which would break
61- pymalloc. To solve these problems, allocate an extra byte. */
62- /* Returns NULL to indicate error if a negative size or size larger than
63- Py_ssize_t can represent is supplied. Helps prevents security holes. */
64- #define PyMem_MALLOC (n ) PyMem_Malloc(n)
65- #define PyMem_REALLOC (p , n ) PyMem_Realloc(p, n)
66- #define PyMem_FREE (p ) PyMem_Free(p)
67-
6856/*
6957 * Type-oriented memory interface
7058 * ==============================
@@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
7866#define PyMem_New (type , n ) \
7967 ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
8068 ( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
81- #define PyMem_NEW (type , n ) \
82- ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
83- ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
8469
8570/*
8671 * The value of (p) is always clobbered by this macro regardless of success.
@@ -91,15 +76,16 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
9176#define PyMem_Resize (p , type , n ) \
9277 ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
9378 (type *) PyMem_Realloc((p), (n) * sizeof(type)) )
94- #define PyMem_RESIZE (p , type , n ) \
95- ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
96- (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
9779
98- /* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
99- * anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
100- */
101- #define PyMem_Del PyMem_Free
102- #define PyMem_DEL PyMem_FREE
80+
81+ // Deprecated aliases only kept for backward compatibility.
82+ #define PyMem_MALLOC (n ) PyMem_Malloc(n)
83+ #define PyMem_NEW (type , n ) PyMem_New(type, n)
84+ #define PyMem_REALLOC (p , n ) PyMem_Realloc(p, n)
85+ #define PyMem_RESIZE (p , type , n ) PyMem_Resize(p, type, n)
86+ #define PyMem_FREE (p ) PyMem_Free(p)
87+ #define PyMem_Del (p ) PyMem_Free(p)
88+ #define PyMem_DEL (p ) PyMem_Free(p)
10389
10490
10591#ifndef Py_LIMITED_API
0 commit comments