Skip to content

Commit

Permalink
Merge pull request #26419 from ngoldbaum/clean-up-array-owned
Browse files Browse the repository at this point in the history
MNT: clean up references to array_owned==2 case in StringDType
  • Loading branch information
charris committed May 10, 2024
2 parents 1c9504f + bc15ac9 commit 766ee27
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions numpy/_core/src/multiarray/stringdtype/dtype.c
Expand Up @@ -33,7 +33,6 @@ new_stringdtype_instance(PyObject *na_object, int coerce)

char *default_string_buf = NULL;
char *na_name_buf = NULL;
char array_owned = 0;

npy_string_allocator *allocator = NpyString_new_allocator(PyMem_RawMalloc, PyMem_RawFree,
PyMem_RawRealloc);
Expand Down Expand Up @@ -138,7 +137,7 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
if (na_name_buf != NULL) {
PyMem_RawFree(na_name_buf);
}
if (allocator != NULL && array_owned != 2) {
if (allocator != NULL) {
NpyString_free_allocator(allocator);
}
return NULL;
Expand Down Expand Up @@ -660,7 +659,7 @@ stringdtype_dealloc(PyArray_StringDTypeObject *self)
{
Py_XDECREF(self->na_object);
// this can be null if an error happens while initializing an instance
if (self->allocator != NULL && self->array_owned != 2) {
if (self->allocator != NULL) {
NpyString_free_allocator(self->allocator);
}
PyMem_RawFree((char *)self->na_name.buf);
Expand Down

0 comments on commit 766ee27

Please sign in to comment.