@@ -20,6 +20,8 @@ struct cstring {
2020 char value [];
2121};
2222
23+ static PyTypeObject cstring_type ;
24+
2325#define CSTRING_HASH (self ) (((struct cstring *)self)->hash)
2426#define CSTRING_VALUE (self ) (((struct cstring *)self)->value)
2527#define CSTRING_VALUE_AT (self , i ) (&CSTRING_VALUE(self)[(i)])
@@ -32,7 +34,9 @@ static PyObject *_cstring_new(PyTypeObject *type, const char *value, size_t len)
3234 return (PyObject * )new ;
3335}
3436
35- #define CSTRING_NEW_EMPTY (tp ) (_cstring_new(tp, "", 0))
37+ static PyObject * cstring_new_empty (void ) {
38+ return _cstring_new (& cstring_type , "" , 0 );
39+ }
3640
3741static PyObject * cstring_new (PyTypeObject * type , PyObject * args , PyObject * kwargs ) {
3842 char * value = NULL ;
@@ -46,8 +50,6 @@ static void cstring_dealloc(PyObject *self) {
4650 Py_TYPE (self )-> tp_free (self );
4751}
4852
49- static PyTypeObject cstring_type ;
50-
5153static int _ensure_cstring (PyObject * self ) {
5254 if (PyObject_TypeCheck (self , & cstring_type ))
5355 return 1 ;
@@ -127,7 +129,7 @@ static PyObject *cstring_repeat(PyObject *self, Py_ssize_t count) {
127129 if (!_ensure_cstring (self ))
128130 return NULL ;
129131 if (count <= 0 )
130- return CSTRING_NEW_EMPTY ( Py_TYPE ( self ) );
132+ return cstring_new_empty ( );
131133
132134 Py_ssize_t size = (cstring_len (self ) * count ) + 1 ;
133135
0 commit comments