- fix compilation with older python versions
[platform/upstream/libsolv.git] / bindings / solv.i
index e64a632..a5b9552 100644 (file)
   int size, i;
   VALUE *o;
   queue_init(&$1);
-  size = RARRAY($input)->len;
+  size = RARRAY_LEN($input);
   i = 0;
-  o = RARRAY($input)->ptr;
+  o = RARRAY_PTR($input);
   for (i = 0; i < size; i++, o++) {
     int v;
     int e = SWIG_AsVal_int(*o, &v);
@@ -370,6 +370,14 @@ typedef VALUE AppObjectPtr;
 #endif
 #include "solv_xfopen.h"
 
+/* for old ruby versions */
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(ary) (RARRAY(ary)->len)
+#endif
+
 #define true 1
 #define false 1
 
@@ -835,7 +843,8 @@ typedef struct {
   %}
   void set_loadcallback(PyObject *callable) {
     if ($self->loadcallback == loadcallback) {
-      Py_DECREF($self->loadcallbackdata);
+      PyObject *obj = $self->loadcallbackdata;
+      Py_DECREF(obj);
     }
     if (callable) {
       Py_INCREF(callable);