8000 Pull request #71: Introduce array_destroy. · hpyproject/numpy-hpy@52e6974 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52e6974

Browse files
committed
Pull request numpy#71: Introduce array_destroy.
Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/array_destroy to labs-hpy-port * commit '308c18df23b9ce2ba6d3e1e380307e3616bd7081': Introduce array_destroy; move cache free from finalize to destroy Fix another leak in hpy_get_view_from_index
2 parents 3423d65 + 308c18d commit 52e6974

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

numpy/core/src/multiarray/arrayobject.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,24 @@ array_finalize_impl(HPyContext *ctx, HPy h_self)
705705
}
706706
}
707707

708+
// TODO HPY LABS PORT: moved to array_destroy
708709
/* must match allocation in PyArray_NewFromDescr */
709-
npy_free_cache_dim(fa->dimensions, 2 * fa->nd);
710+
// npy_free_cache_dim(fa->dimensions, 2 * fa->nd);
710711

711712
// PyErr_Restore(error_type, error_value, error_traceback);
712713
}
713714

715+
/* array object functions */
716+
HPyDef_SLOT(array_destroy, array_destroy_impl, HPy_tp_destroy)
717+
static void
718+
array_destroy_impl(void *data)
719+
{
720+
PyArrayObject_fields *fa = (PyArrayObject_fields *)data;
721+
722+
/* must match allocation in PyArray_NewFromDescr */
723+
npy_free_cache_dim(fa->dimensions, 2 * fa->nd);
724+
}
725+
714726
HPyDef_SLOT(array_traverse, array_traverse_impl, HPy_tp_traverse)
715727
static int
716728
array_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg)
@@ -2085,6 +2097,7 @@ static HPyDef *array_defines[] = {
20852097
&array_new,
20862098
&array_traverse,
20872099
&array_finalize,
2100+
&array_destroy,
20882101
&array_inplace_add,
20892102
&array_power,
20902103
&array_subtract,

numpy/core/src/multiarray/mapping.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,8 @@ hpy_get_view_from_index(HPyContext *ctx, HPy h_self, PyArrayObject *self, HPy *v
16771677
PyArray_FLAGS(self),
16781678
ensure_array ? HPy_NULL : h_self,
16791679
h_self);
1680+
HPy_Close(ctx, h_descr);
1681+
HPy_Close(ctx, h_type);
16801682
if (HPy_IsNull(*view)) {
16811683
return -1;
16821684
}

0 commit comments

Comments
 (0)
0