Skip to content

Commit 7925b95

Browse files
committed
Fix problematic FastqRecordArrayView initialization
1 parent 05d4ebd commit 7925b95

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/sequali/_qcmodule.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ along with Sequali. If not, see <https://www.gnu.org/licenses/
3232
#include "emmintrin.h"
3333
#endif
3434

35-
#if (PY_VERSION_HEX < 0x03090000)
36-
#define Py_SET_REFCNT(op, count) (Py_REFCNT(op) = count)
37-
#define Py_SET_SIZE(op, size) (Py_SIZE(op) = size)
38-
#define Py_SET_TYPE(op, type) (Py_TYPE(op) = type)
39-
#endif
40-
4135
/* Pointers to types that will be imported in the module initialization section */
4236

4337
static PyTypeObject *PythonArray; // array.array
@@ -538,14 +532,11 @@ FastqRecordArrayView_FromPointerSizeAndObject(struct FastqMeta *records,
538532
PyObject *obj)
539533
{
540534
size_t size = number_of_records * sizeof(struct FastqMeta);
541-
FastqRecordArrayView *self =
542-
PyObject_Malloc(sizeof(FastqRecordArrayView) + size);
535+
FastqRecordArrayView *self = PyObject_NewVar(
536+
FastqRecordArrayView, &FastqRecordArrayView_Type, number_of_records);
543537
if (self == NULL) {
544538
return PyErr_NoMemory();
545539
}
546-
Py_SET_REFCNT(self, 1);
547-
Py_SET_TYPE(self, &FastqRecordArrayView_Type);
548-
Py_SET_SIZE(self, number_of_records);
549540
if (records != NULL) {
550541
memcpy(self->records, records, size);
551542
}

0 commit comments

Comments
 (0)