From 3ea60eec166d73e4eb221f7bcf729a2a825ce66f Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Thu, 3 Oct 2024 17:01:14 +0100 Subject: [PATCH] Probably correct fix for multiiter size Thanks to Sebastian's comments at: https://github.com/numpy/numpy/issues/26765#issuecomment-2391737671 --- lib/fff_python_wrapper/fffpy.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/fff_python_wrapper/fffpy.c b/lib/fff_python_wrapper/fffpy.c index ca2a9e063..718c358ed 100644 --- a/lib/fff_python_wrapper/fffpy.c +++ b/lib/fff_python_wrapper/fffpy.c @@ -523,13 +523,11 @@ fffpy_multi_iterator* fffpy_multi_iterator_new(int narr, int axis, ...) /* Create new instance */ thisone = (fffpy_multi_iterator*)malloc(sizeof(fffpy_multi_iterator)); - /* Size of PyArrayMultiIterObject no longer guaranteed. + /* Static size of PyArrayMultiIterObject. * - * Add arbitrary overhead to allow for this. - * - * https://github.com/numpy/numpy/issues/26765#issuecomment-2189047480 + * https://github.com/numpy/numpy/issues/26765#issuecomment-2391737671 */ - multi = PyArray_malloc(sizeof(PyArrayMultiIterObject) * 2); + multi = PyArray_malloc(PyArrayMultiIter_Type.tp_basicsize); vector = (fff_vector**)malloc(narr*sizeof(fff_vector*)); /* Initialize the PyArrayMultiIterObject instance from the variadic arguments */