X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=bindings%2Fpython%2Frrdtoolmodule.c;h=109d66f3194d7b0c5c45a57d96559631dcdf31f4;hb=7a260c0749609acfb2baa794e8284e06c20eb88a;hp=37810f7c08fc47edb560ba9cd08c19d74d6a490e;hpb=0d0b72e9bcf127f9865f6c6c4c7d9c1885efc4b0;p=rrdtool.git diff --git a/bindings/python/rrdtoolmodule.c b/bindings/python/rrdtoolmodule.c index 37810f7..109d66f 100644 --- a/bindings/python/rrdtoolmodule.c +++ b/bindings/python/rrdtoolmodule.c @@ -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; }