We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 16f30e5 commit 386772cCopy full SHA for 386772c
include/pybind11/cast.h
@@ -380,10 +380,14 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
380
space += tinfo->holder_size_in_ptrs;
381
}
382
383
- // Allocate space for flags, values, and holders:
+ // Allocate space for flags, values, and holders; initialize the space to 0 (flags and
384
+ // values need to be 0, and it doesn't hurt the holders)
385
+#if PY_VERSION_HEX >= 0x03050000
386
+ values_and_holders = (void **) PyMem_Calloc(space, sizeof(void *));
387
+#else
388
values_and_holders = (void **) PyMem_New(void *, space);
- // flags and values need to start out equal to 0; it doesn't hurt the holders
389
std::memset(values_and_holders, 0, space * sizeof(void *));
390
+#endif
391
392
owned = true;
393
0 commit comments