Skip to content

Commit 56ff099

Browse files
committed
namespace static string sentinel macros
1 parent 74e97fd commit 56ff099

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

stringdtype/stringdtype/src/casts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ string_to_pylong(char *in, int hasnull)
525525
"integers");
526526
return NULL;
527527
}
528-
s = &EMPTY_STRING;
528+
s = &NPY_EMPTY_STRING;
529529
}
530530
PyObject *val_obj =
531531
PyUnicode_FromStringAndSize(npy_string_buf(s), npy_string_size(s));
@@ -778,7 +778,7 @@ string_to_pyfloat(char *in, int hasnull)
778778
"integers");
779779
return NULL;
780780
}
781-
s = &EMPTY_STRING;
781+
s = &NPY_EMPTY_STRING;
782782
}
783783
PyObject *val_obj =
784784
PyUnicode_FromStringAndSize(npy_string_buf(s), npy_string_size(s));

stringdtype/stringdtype/src/dtype.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ new_stringdtype_instance(PyObject *na_object, int coerce)
2020

2121
Py_XINCREF(na_object);
2222
((StringDTypeObject *)new)->na_object = na_object;
23-
npy_static_string na_name = NULL_STRING;
23+
npy_static_string na_name = NPY_NULL_STRING;
2424
int hasnull = na_object != NULL;
2525
int has_nan_na = 0;
2626
int has_string_na = 0;
27-
npy_static_string default_string = EMPTY_STRING;
27+
npy_static_string default_string = NPY_EMPTY_STRING;
2828
if (hasnull) {
2929
// first check for a string
3030
if (PyUnicode_Check(na_object)) {
3131
has_string_na = 1;
3232
Py_ssize_t size = 0;
3333
const char *buf = PyUnicode_AsUTF8AndSize(na_object, &size);
34-
default_string = NULL_STRING;
34+
default_string = NPY_NULL_STRING;
3535
int res = npy_string_newsize(buf, (size_t)size, &default_string);
3636
if (res == -1) {
3737
PyErr_NoMemory();

stringdtype/stringdtype/src/static_string.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "static_string.h"
44

5-
// defined this way so EMPTY_STRING has an in-memory representation that is
6-
// distinct from a zero-filled struct, allowing us to use a NULL_STRING
5+
// defined this way so NPY_EMPTY_STRING has an in-memory representation that is
6+
// distinct from a zero-filled struct, allowing us to use a NPY_NULL_STRING
77
// to represent a sentinel value
8-
const npy_static_string EMPTY_STRING = {0, "\0"};
9-
const npy_static_string NULL_STRING = {0, NULL};
8+
const npy_static_string NPY_EMPTY_STRING = {0, "\0"};
9+
const npy_static_string NPY_NULL_STRING = {0, NULL};
1010

1111
int
1212
npy_string_newsize(const char *init, size_t size, npy_static_string *to_init)
@@ -17,7 +17,7 @@ npy_string_newsize(const char *init, size_t size, npy_static_string *to_init)
1717
}
1818

1919
if (size == 0) {
20-
*to_init = EMPTY_STRING;
20+
*to_init = NPY_EMPTY_STRING;
2121
return 0;
2222
}
2323

@@ -39,7 +39,7 @@ npy_string_newsize(const char *init, size_t size, npy_static_string *to_init)
3939
void
4040
npy_string_free(npy_static_string *str)
4141
{
42-
if (str->buf != NULL && str->buf != EMPTY_STRING.buf) {
42+
if (str->buf != NULL && str->buf != NPY_EMPTY_STRING.buf) {
4343
PyMem_RawFree(str->buf);
4444
str->buf = NULL;
4545
}
@@ -69,7 +69,7 @@ npy_string_newemptysize(size_t size, npy_static_string *out)
6969
out->size = size;
7070

7171
if (size == 0) {
72-
*out = EMPTY_STRING;
72+
*out = NPY_EMPTY_STRING;
7373
return 0;
7474
}
7575

stringdtype/stringdtype/src/static_string.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ typedef struct npy_static_string {
1111

1212
// represents the empty string and can be passed safely to npy_static_string
1313
// API functions
14-
extern const npy_static_string EMPTY_STRING;
14+
extern const npy_static_string NPY_EMPTY_STRING;
1515
// represents a sentinel value, *CANNOT* be passed safely to npy_static_string
1616
// API functions, use npy_string_isnull to check if a value is null before
1717
// working with it.
18-
extern const npy_static_string NULL_STRING;
18+
extern const npy_static_string NPY_NULL_STRING;
1919

2020
// Allocates a new buffer for *to_init*, which must be set to NULL before
2121
// calling this function, filling the newly allocated buffer with the copied

0 commit comments

Comments
 (0)