projects
/
linpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Oops, fix relative imports
[linpy.git]
/
pypol
/
_isl.c
diff --git
a/pypol/_isl.c
b/pypol/_isl.c
index
fe29ec5
..
b9d6092
100644
(file)
--- a/
pypol/_isl.c
+++ b/
pypol/_isl.c
@@
-1,5
+1,4
@@
#include <Python.h>
#include <Python.h>
-#include <stdlib.h>
#include <isl/constraint.h>
#include <isl/set.h>
#include <isl/constraint.h>
#include <isl/set.h>
@@
-13,10
+12,15
@@
typedef struct _isl_constraint_list _isl_constraint_list;
int _isl_isl_basic_set_add_constraint_list(__isl_take isl_constraint *c,
void *user) {
_isl_constraint_list *list;
int _isl_isl_basic_set_add_constraint_list(__isl_take isl_constraint *c,
void *user) {
_isl_constraint_list *list;
+ PyObject *value;
list = (_isl_constraint_list *) user;
list = (_isl_constraint_list *) user;
- return PyList_SetItem(list->constraints, list->cursor++,
- PyLong_FromVoidPtr(c));
+ value = PyLong_FromVoidPtr(c);
+ if (value == NULL) {
+ return -1;
+ }
+ PyList_SET_ITEM(list->constraints, list->cursor++, value);
+ return 0;
}
static PyObject * _isl_isl_basic_set_constraints(PyObject *self,
}
static PyObject * _isl_isl_basic_set_constraints(PyObject *self,
@@
-31,13
+35,31
@@
static PyObject * _isl_isl_basic_set_constraints(PyObject *self,
return NULL;
bset = (isl_basic_set*) ptr;
n = isl_basic_set_n_constraint(bset);
return NULL;
bset = (isl_basic_set*) ptr;
n = isl_basic_set_n_constraint(bset);
+ if (n == -1) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "an error occurred in isl_basic_set_n_constraint");
+ return NULL;
+ }
constraints = PyList_New(n);
constraints = PyList_New(n);
+ if (constraints == NULL) {
+ return NULL;
+ }
list = malloc(sizeof(_isl_constraint_list));
list = malloc(sizeof(_isl_constraint_list));
+ if (list == NULL) {
+ Py_DECREF(constraints);
+ return PyErr_NoMemory();
+ }
list->cursor = 0;
list->constraints = constraints;
list->cursor = 0;
list->constraints = constraints;
- isl_basic_set_foreach_constraint(bset,
+
n =
isl_basic_set_foreach_constraint(bset,
_isl_isl_basic_set_add_constraint_list, list);
free(list);
_isl_isl_basic_set_add_constraint_list, list);
free(list);
+ if (n == -1) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "an error occurred in isl_basic_set_foreach_constraint");
+ Py_DECREF(constraints);
+ return NULL;
+ }
return constraints;
}
return constraints;
}
@@
-50,17
+72,20
@@
static struct PyModuleDef _islmodule = {
PyModuleDef_HEAD_INIT,
"_isl",
NULL,
PyModuleDef_HEAD_INIT,
"_isl",
NULL,
-
-1
,
+
0
,
_isl_methods
};
PyMODINIT_FUNC PyInit__isl(void) {
PyObject *m;
m = PyModule_Create(&_islmodule);
_isl_methods
};
PyMODINIT_FUNC PyInit__isl(void) {
PyObject *m;
m = PyModule_Create(&_islmodule);
- if (m == NULL)
+ if (m == NULL)
{
return NULL;
return NULL;
+ }
- PyModule_AddObject(m, "isl_dim_set", PyLong_FromLong(isl_dim_set));
+ if (PyModule_AddObject(m, "isl_dim_set", PyLong_FromLong(isl_dim_set)) == -1) {
+ return NULL;
+ }
return m;
}
return m;
}