Skip to content

Commit e03b2f8

Browse files
committed
Add missing C API function PyMem_Calloc
1 parent 4107acf commit e03b2f8

File tree

1 file changed

+7
-0
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+7
-0
lines changed

graalpython/com.oracle.graal.python.cext/src/obmalloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ void* PyMem_Malloc(size_t size) {
109109
return ptr;
110110
}
111111

112+
void* PyMem_Calloc(size_t nelem, size_t elsize) {
113+
if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize) {
114+
return NULL;
115+
}
116+
return PyMem_RawCalloc(nelem, elsize);
117+
}
118+
112119
void* PyMem_RawMalloc(size_t size) {
113120
mem_head_t* ptr_with_head = malloc((size == 0 ? 1 : size) + sizeof(mem_head_t));
114121
void* ptr = FROM_MEM_HEAD(ptr_with_head);

0 commit comments

Comments
 (0)