@@ -23,8 +23,8 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
2323 return NULL ;
2424 }
2525
26- allocator = npy_string_new_allocator (PyMem_RawMalloc , PyMem_RawFree ,
27- PyMem_RawRealloc );
26+ allocator = NpyString_new_allocator (PyMem_RawMalloc , PyMem_RawFree ,
27+ PyMem_RawRealloc );
2828
2929 if (allocator == NULL ) {
3030 PyErr_SetString (PyExc_MemoryError ,
@@ -49,8 +49,8 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
4949 has_string_na = 1 ;
5050 Py_ssize_t size = 0 ;
5151 const char * buf = PyUnicode_AsUTF8AndSize (na_object , & size );
52- if (npy_string_newsize (buf , (size_t )size , & packed_default_string ,
53- allocator ) < 0 ) {
52+ if (NpyString_newsize (buf , (size_t )size , & packed_default_string ,
53+ allocator ) < 0 ) {
5454 PyErr_SetString (PyExc_MemoryError ,
5555 "Failed to allocate string while creating "
5656 "StringDType instance." );
@@ -86,8 +86,8 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
8686 Py_DECREF (na_pystr );
8787 goto fail ;
8888 }
89- if (npy_string_newsize (utf8_ptr , (size_t )size , & packed_na_name ,
90- allocator ) < 0 ) {
89+ if (NpyString_newsize (utf8_ptr , (size_t )size , & packed_na_name ,
90+ allocator ) < 0 ) {
9191 PyErr_SetString (PyExc_MemoryError ,
9292 "Failed to allocate string while creating "
9393 "StringDType instance." );
@@ -109,8 +109,8 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
109109 snew -> array_owned = 0 ;
110110
111111 npy_static_string default_string = {0 , NULL };
112- if (npy_string_load (allocator , & snew -> packed_default_string ,
113- & default_string ) == -1 ) {
112+ if (NpyString_load (allocator , & snew -> packed_default_string ,
113+ & default_string ) == -1 ) {
114114 PyErr_SetString (PyExc_MemoryError ,
115115 "Failed to load packed string while "
116116 "creating StringDType instance." );
@@ -119,7 +119,7 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
119119 }
120120
121121 npy_static_string na_name = {0 , NULL };
122- if (npy_string_load (allocator , & snew -> packed_na_name , & na_name ) == -1 ) {
122+ if (NpyString_load (allocator , & snew -> packed_na_name , & na_name ) == -1 ) {
123123 PyErr_SetString (PyExc_MemoryError ,
124124 "Failed to load packed string while "
125125 "creating StringDType instance." );
@@ -150,9 +150,9 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
150150 // this only makes sense if the allocator isn't attached to new yet
151151 Py_DECREF (new );
152152 if (allocator != NULL ) {
153- npy_string_free (& packed_na_name , allocator );
154- npy_string_free (& packed_default_string , allocator );
155- npy_string_free_allocator (allocator );
153+ NpyString_free (& packed_na_name , allocator );
154+ NpyString_free (& packed_default_string , allocator );
155+ NpyString_free_allocator (allocator );
156156 }
157157 if (allocator_lock != NULL ) {
158158 PyThread_free_lock (allocator_lock );
@@ -291,7 +291,7 @@ stringdtype_setitem(StringDTypeObject *descr, PyObject *obj, char **dataptr)
291291
292292 // free if dataptr holds preexisting string data,
293293 // npy_string_free does a NULL check and checks for small strings
294- if (npy_string_free (sdata , descr -> allocator ) < 0 ) {
294+ if (NpyString_free (sdata , descr -> allocator ) < 0 ) {
295295 PyErr_SetString (PyExc_MemoryError ,
296296 "String deallocation failed in StringDType setitem" );
297297 goto fail ;
@@ -319,7 +319,7 @@ stringdtype_setitem(StringDTypeObject *descr, PyObject *obj, char **dataptr)
319319 goto fail ;
320320 }
321321
322- if (npy_string_newsize (val , length , sdata , descr -> allocator ) < 0 ) {
322+ if (NpyString_newsize (val , length , sdata , descr -> allocator ) < 0 ) {
323323 PyErr_SetString (PyExc_MemoryError ,
324324 "Failed to allocate string during StringDType "
325325 "setitem" );
@@ -347,7 +347,7 @@ stringdtype_getitem(StringDTypeObject *descr, char **dataptr)
347347 npy_static_string sdata = {0 , NULL };
348348 int hasnull = descr -> na_object != NULL ;
349349 NPY_STRING_ACQUIRE_ALLOCATOR (descr );
350- int is_null = npy_string_load (descr -> allocator , psdata , & sdata );
350+ int is_null = NpyString_load (descr -> allocator , psdata , & sdata );
351351
352352 if (is_null < 0 ) {
353353 PyErr_SetString (PyExc_MemoryError ,
@@ -399,7 +399,7 @@ stringdtype_getitem(StringDTypeObject *descr, char **dataptr)
399399npy_bool
400400nonzero (void * data , void * NPY_UNUSED (arr ))
401401{
402- return npy_string_size ((npy_packed_static_string * )data ) != 0 ;
402+ return NpyString_size ((npy_packed_static_string * )data ) != 0 ;
403403}
404404
405405// Implementation of PyArray_CompareFunc.
@@ -429,10 +429,10 @@ _compare(void *a, void *b, StringDTypeObject *descr_a,
429429 npy_static_string * default_string = & descr_a -> default_string ;
430430 const npy_packed_static_string * ps_a = (npy_packed_static_string * )a ;
431431 npy_static_string s_a = {0 , NULL };
432- int a_is_null = npy_string_load (allocator_a , ps_a , & s_a );
432+ int a_is_null = NpyString_load (allocator_a , ps_a , & s_a );
433433 const npy_packed_static_string * ps_b = (npy_packed_static_string * )b ;
434434 npy_static_string s_b = {0 , NULL };
435- int b_is_null = npy_string_load (allocator_b , ps_b , & s_b );
435+ int b_is_null = NpyString_load (allocator_b , ps_b , & s_b );
436436 if (NPY_UNLIKELY (a_is_null == -1 || b_is_null == -1 )) {
437437 char * msg = "Failed to load string in string comparison" ;
438438 if (hasnull && !(has_string_na && has_nan_na )) {
@@ -476,7 +476,7 @@ _compare(void *a, void *b, StringDTypeObject *descr_a,
476476 }
477477 }
478478 }
479- return npy_string_cmp (& s_a , & s_b );
479+ return NpyString_cmp (& s_a , & s_b );
480480}
481481
482482// PyArray_ArgFunc
@@ -526,7 +526,7 @@ stringdtype_clear_loop(void *NPY_UNUSED(traverse_context),
526526 while (size -- ) {
527527 npy_packed_static_string * sdata = (npy_packed_static_string * )data ;
528528 if (data != NULL ) {
529- if (npy_string_free (sdata , sdescr -> allocator ) < 0 ) {
529+ if (NpyString_free (sdata , sdescr -> allocator ) < 0 ) {
530530 gil_error (PyExc_MemoryError ,
531531 "String deallocation failed in clear loop" );
532532 goto fail ;
@@ -703,9 +703,9 @@ stringdtype_dealloc(StringDTypeObject *self)
703703 if (self -> allocator != NULL ) {
704704 // can we assume the destructor for an instance will only get called
705705 // inside of one C thread?
706- npy_string_free (& self -> packed_default_string , self -> allocator );
707- npy_string_free (& self -> packed_na_name , self -> allocator );
708- npy_string_free_allocator (self -> allocator );
706+ NpyString_free (& self -> packed_default_string , self -> allocator );
707+ NpyString_free (& self -> packed_na_name , self -> allocator );
708+ NpyString_free_allocator (self -> allocator );
709709 PyThread_free_lock (self -> allocator_lock );
710710 }
711711 PyArrayDescr_Type .tp_dealloc ((PyObject * )self );
@@ -958,14 +958,14 @@ free_and_copy(npy_string_allocator *in_allocator,
958958 const npy_packed_static_string * in ,
959959 npy_packed_static_string * out , const char * location )
960960{
961- if (npy_string_free (out , out_allocator ) < 0 ) {
961+ if (NpyString_free (out , out_allocator ) < 0 ) {
962962 char message [200 ];
963963 snprintf (message , sizeof (message ), "Failed to deallocate string in %s" ,
964964 location );
965965 gil_error (PyExc_MemoryError , message );
966966 return -1 ;
967967 }
968- if (npy_string_dup (in , out , in_allocator , out_allocator ) < 0 ) {
968+ if (NpyString_dup (in , out , in_allocator , out_allocator ) < 0 ) {
969969 char message [200 ];
970970 snprintf (message , sizeof (message ), "Failed to allocate string in %s" ,
971971 location );
0 commit comments