summaryrefslogtreecommitdiffstats
path: root/Include/pymem.h
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-05-02 20:31:14 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-05-02 20:31:14 (GMT)
commitdb067af12a5ebb889874e47d8177f9c4a3dc9a68 (patch)
tree87cea7c1fb4a0905ac2632c03520c43f377b3584 /Include/pymem.h
parentd50c3f3f3af54f3be46d26d53a1c10b7c15a7b2d (diff)
downloadcpython-db067af12a5ebb889874e47d8177f9c4a3dc9a68.zip
cpython-db067af12a5ebb889874e47d8177f9c4a3dc9a68.tar.gz
cpython-db067af12a5ebb889874e47d8177f9c4a3dc9a68.tar.bz2
Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(),
PyObject_Calloc(), _PyObject_GC_Calloc(). bytes(int) and bytearray(int) are now using ``calloc()`` instead of ``malloc()`` for large objects which is faster and use less memory (until the bytearray buffer is filled with data).
Diffstat (limited to 'Include/pymem.h')
-rw-r--r--Include/pymem.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/Include/pymem.h b/Include/pymem.h
index 2372b86..7a8dd43 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -13,6 +13,7 @@ extern "C" {
#ifndef Py_LIMITED_API
PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
+PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
#endif
@@ -57,6 +58,7 @@ PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
*/
PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
+PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);
@@ -132,6 +134,9 @@ typedef struct {
/* allocate a memory block */
void* (*malloc) (void *ctx, size_t size);
+ /* allocate a memory block initialized by zeros */
+ void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
+
/* allocate or resize a memory block */
void* (*realloc) (void *ctx, void *ptr, size_t new_size);