+
+#include <isl/constraint.h>
+#include <isl/set.h>
+
+struct pointer_list {
+ int cursor;
+ PyObject *pointers;
+};
+typedef struct pointer_list pointer_list;
+
+static int pointer_list_append_constraint(isl_constraint *c, void *user) {
+ pointer_list *list;
+ PyObject *value;
+
+ list = (pointer_list *) user;
+ value = PyLong_FromVoidPtr(c);
+ if (value == NULL) {
+ return -1;
+ }
+ PyList_SET_ITEM(list->pointers, list->cursor++, value);
+ return 0;
+}
+
+static PyObject * basic_set_constraints(PyObject *self, PyObject* args) {
+ long ptr;
+ isl_basic_set *bset;
+ int n;
+ PyObject *pointers;
+ pointer_list *list;
+
+ if (!PyArg_ParseTuple(args, "l", &ptr))
+ 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;
+ }
+ pointers = PyList_New(n);
+ if (pointers == NULL) {
+ return NULL;
+ }
+ list = malloc(sizeof(pointer_list));
+ if (list == NULL) {
+ Py_DECREF(pointers);
+ return PyErr_NoMemory();
+ }
+ list->cursor = 0;
+ list->pointers = pointers;
+ n = isl_basic_set_foreach_constraint(bset, pointer_list_append_constraint,
+ list);
+ free(list);
+ if (n == -1) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "an error occurred in isl_basic_set_foreach_constraint");
+ Py_DECREF(pointers);
+ return NULL;
+ }
+ return pointers;
+}