Skip to content

Commit 08f7d98

Browse files
committed
Cast new cstring objects
1 parent ae26652 commit 08f7d98

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cstring.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct cstring {
1212

1313

1414
static PyObject *_cstring_new(PyTypeObject *type, const char *value, size_t len) {
15-
struct cstring *new = type->tp_alloc(type, len + 1);
15+
struct cstring *new = (struct cstring *)type->tp_alloc(type, len + 1);
1616
new->hash = -1;
1717
memcpy(new->value, value, len);
1818
new->value[len] = '\0';
@@ -102,7 +102,7 @@ static PyObject *cstring_concat(PyObject *left, PyObject *right) {
102102

103103
Py_ssize_t size = cstring_len(left) + cstring_len(right) + 1;
104104

105-
struct cstring *new = Py_TYPE(left)->tp_alloc(Py_TYPE(left), size);
105+
struct cstring *new = (struct cstring *)Py_TYPE(left)->tp_alloc(Py_TYPE(left), size);
106106
memcpy(new->value, CSTRING_VALUE(left), Py_SIZE(left));
107107
memcpy(&new->value[cstring_len(left)], CSTRING_VALUE(right), Py_SIZE(right));
108108
return (PyObject *)new;
@@ -116,7 +116,7 @@ static PyObject *cstring_repeat(PyObject *self, Py_ssize_t count) {
116116

117117
Py_ssize_t size = (cstring_len(self) * count) + 1;
118118

119-
struct cstring *new = Py_TYPE(self)->tp_alloc(Py_TYPE(self), size);
119+
struct cstring *new = (struct cstring *)Py_TYPE(self)->tp_alloc(Py_TYPE(self), size);
120120
for(Py_ssize_t i = 0; i < size - 1; i += cstring_len(self)) {
121121
memcpy(&new->value[i], CSTRING_VALUE(self), Py_SIZE(self));
122122
}
@@ -160,7 +160,7 @@ static PyObject *_cstring_subscript_slice(PyObject *self, PyObject *slice) {
160160
Py_ssize_t slicelen = PySlice_AdjustIndices(cstring_len(self), &start, &stop, step);
161161
assert(slicelen >= 0);
162162

163-
struct cstring *new = Py_TYPE(self)->tp_alloc(Py_TYPE(self), slicelen + 1);
163+
struct cstring *new = (struct cstring *)Py_TYPE(self)->tp_alloc(Py_TYPE(self), slicelen + 1);
164164
char *src = CSTRING_VALUE_AT(self, start);
165165
for(Py_ssize_t i = 0; i < slicelen; ++i) {
166166
new->value[i] = *src;

0 commit comments

Comments
 (0)