Code

Imported upstream version 1.3rc9.
[pkg-rrdtool.git] / bindings / python / rrdtoolmodule.c
index 37810f7c08fc47edb560ba9cd08c19d74d6a490e..109d66f3194d7b0c5c45a57d96559631dcdf31f4 100644 (file)
@@ -219,9 +219,9 @@ static PyObject *PyRRD_fetch(
         }
 
         for (i = 0; i < ds_cnt; i++)
-            free(ds_namv[i]);
-        free(ds_namv);  /* rrdtool don't use PyMem_Malloc :) */
-        free(data);
+            rrd_freemem(ds_namv[i]);
+        rrd_freemem(ds_namv);  /* rrdtool don't use PyMem_Malloc :) */
+        rrd_freemem(data);
     }
 
     destroy_args(&argv);
@@ -282,9 +282,9 @@ static PyObject *PyRRD_graph(
                 t = PyString_FromString(calcpr[i]);
                 PyList_Append(e, t);
                 Py_DECREF(t);
-                free(calcpr[i]);
+                rrd_freemem(calcpr[i]);
             }
-            free(calcpr);
+            rrd_freemem(calcpr);
         } else {
             Py_INCREF(Py_None);
             PyTuple_SET_ITEM(r, 2, Py_None);
@@ -404,17 +404,19 @@ static PyObject *PyRRD_resize(
 }
 
 static PyObject *PyDict_FromInfo(
-    info_t *data)
+    rrd_info_t *data)
 {
     PyObject *r;
+
     r = PyDict_New();
-    while (data){
+    while (data) {
         PyObject *val = NULL;
+
         switch (data->type) {
         case RD_I_VAL:
-            val = isnan(data->value.u_val)     
-                    ? (Py_INCREF(Py_None), Py_None)     
-                    : PyFloat_FromDouble(data->value.u_val);
+            val = isnan(data->value.u_val)
+                ? (Py_INCREF(Py_None), Py_None)
+                : PyFloat_FromDouble(data->value.u_val);
             break;
         case RD_I_CNT:
             val = PyLong_FromUnsignedLong(data->value.u_cnt);
@@ -426,11 +428,13 @@ static PyObject *PyDict_FromInfo(
             val = PyString_FromString(data->value.u_str);
             break;
         case RD_I_BLO:
-            val = PyString_FromStringAndSize((char*)data->value.u_blo.ptr, data->value.u_blo.size);
+            val =
+                PyString_FromStringAndSize((char *) data->value.u_blo.ptr,
+                                           data->value.u_blo.size);
             break;
         }
-        if (val){
-            PyDict_SetItemString(r,data->key,val);
+        if (val) {
+            PyDict_SetItemString(r, data->key, val);
         }
         data = data->next;
     }
@@ -447,18 +451,18 @@ static PyObject *PyRRD_info(
     PyObject *r;
     int       argc;
     char    **argv;
-    info_t   *data;
+    rrd_info_t *data;
 
-    if (create_args("info", args, &argc, &argv) < 0)  
+    if (create_args("info", args, &argc, &argv) < 0)
         return NULL;
-     
+
     if ((data = rrd_info(argc, argv)) == NULL) {
         PyErr_SetString(ErrorObject, rrd_get_error());
         rrd_clear_error();
         return NULL;
     }
     r = PyDict_FromInfo(data);
-    info_free(data);
+    rrd_info_free(data);
     return r;
 }
 
@@ -472,18 +476,18 @@ static PyObject *PyRRD_graphv(
     PyObject *r;
     int       argc;
     char    **argv;
-    info_t   *data;
+    rrd_info_t *data;
 
-    if (create_args("graphv", args, &argc, &argv) < 0)  
+    if (create_args("graphv", args, &argc, &argv) < 0)
         return NULL;
-     
+
     if ((data = rrd_graph_v(argc, argv)) == NULL) {
         PyErr_SetString(ErrorObject, rrd_get_error());
         rrd_clear_error();
         return NULL;
     }
     r = PyDict_FromInfo(data);
-    info_free(data);
+    rrd_info_free(data);
     return r;
 }
 
@@ -497,18 +501,18 @@ static PyObject *PyRRD_updatev(
     PyObject *r;
     int       argc;
     char    **argv;
-    info_t   *data;
+    rrd_info_t *data;
 
-    if (create_args("updatev", args, &argc, &argv) < 0)  
+    if (create_args("updatev", args, &argc, &argv) < 0)
         return NULL;
-     
+
     if ((data = rrd_update_v(argc, argv)) == NULL) {
         PyErr_SetString(ErrorObject, rrd_get_error());
         rrd_clear_error();
         return NULL;
     }
     r = PyDict_FromInfo(data);
-    info_free(data);
+    rrd_info_free(data);
     return r;
 }