bindings: python: don't force python to use the system allocator
authorBartosz Golaszewski <bartekgola@gmail.com>
Sun, 22 Jul 2018 19:26:47 +0000 (21:26 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 22 Jul 2018 19:26:47 +0000 (21:26 +0200)
When allocating raw memory let python decide which allocator to use.
Convert all calls to PyMem_Raw*() to PyMem_*().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/python/gpiodmodule.c

index b0f827953ffc7d93343d1156d80787d8507f49d9..f90ccd5dc43bc9b4129f3461e7608902a41045ce 100644 (file)
@@ -726,7 +726,7 @@ static int gpiod_LineBulk_init(gpiod_LineBulkObject *self, PyObject *args)
                return -1;
        }
 
-       self->lines = PyMem_RawCalloc(self->num_lines, sizeof(PyObject *));
+       self->lines = PyMem_Calloc(self->num_lines, sizeof(PyObject *));
        if (!self->lines) {
                PyErr_SetString(PyExc_MemoryError, "Out of memory");
                return -1;
@@ -734,7 +734,7 @@ static int gpiod_LineBulk_init(gpiod_LineBulkObject *self, PyObject *args)
 
        iter = PyObject_GetIter(lines);
        if (!iter) {
-               PyMem_RawFree(self->lines);
+               PyMem_Free(self->lines);
                return -1;
        }
 
@@ -766,7 +766,7 @@ errout:
                for (--i; i >= 0; i--)
                        Py_DECREF(self->lines[i]);
        }
-       PyMem_RawFree(self->lines);
+       PyMem_Free(self->lines);
        self->lines = NULL;
 
        return -1;
@@ -782,7 +782,7 @@ static void gpiod_LineBulk_dealloc(gpiod_LineBulkObject *self)
        for (i = 0; i < self->num_lines; i++)
                Py_DECREF(self->lines[i]);
 
-       PyMem_RawFree(self->lines);
+       PyMem_Free(self->lines);
 }
 
 static PyObject *gpiod_LineBulk_iternext(gpiod_LineBulkObject *self)