Code

use the standart info free function
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 31 Aug 2008 10:52:49 +0000 (10:52 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 31 Aug 2008 10:52:49 +0000 (10:52 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1473 a5681a0c-68f1-0310-ab6d-d61299d08faa

program/bindings/perl-shared/RRDs.xs
program/bindings/ruby/main.c

index bf9a6123ec6f6e23ab9e75c68a1dad80e9f13e4e..25d44a51c555aa30312608e803fd4c121998dfc8 100644 (file)
@@ -78,8 +78,8 @@ extern "C" {
                free(argv); \
                 if (rrd_test_error()) XSRETURN_UNDEF; \
                 hash = newHV(); \
+               save=data; \
                 while (data) { \
-                   save=data; \
                /* the newSV will get copied by hv so we create it as a mortal \
            to make sure it does not keep hanging round after the fact */ \
                    switch (data->type) { \
@@ -97,18 +97,14 @@ extern "C" {
                        break; \
                    case RD_I_STR: \
                        hvs(newSVpv(data->value.u_str,0)); \
-                       rrd_freemem(data->value.u_str); \
                        break; \
                    case RD_I_BLO: \
                        hvs(newSVpv(data->value.u_blo.ptr,data->value.u_blo.size)); \
-                       rrd_freemem(data->value.u_blo.ptr); \
                        break; \
                    } \
-                   rrd_freemem(data->key); \
                    data = data->next; \
-                   rrd_freemem(save); \
-                   } \
-            rrd_freemem(data); \
+               } \
+            rrd_info_free(save); \
             RETVAL = newRV_noinc((SV*)hash);
 
 /*
index 0648840e9bdd0b9850118d2c988c22f0d12f91b7..d2a7ace09b1b05ad9b3aad2bb401e2ae614afcbf 100644 (file)
@@ -155,6 +155,7 @@ VALUE rb_rrd_infocall(
 
     RRD_CHECK_ERROR result = rb_hash_new();
 
+    p = data;
     while (data) {
         VALUE     key = rb_str_new2(data->key);
 
@@ -171,19 +172,16 @@ VALUE rb_rrd_infocall(
             break;
         case RD_I_STR:
             rb_hash_aset(result, key, rb_str_new2(data->value.u_str));
-            rrd_freemem(data->value.u_str);
             break;
         case RD_I_BLO:
             rb_hash_aset(result, key,
                          rb_str_new(data->value.u_blo.ptr,
                                     data->value.u_blo.size));
-            rrd_freemem(data->value.u_blo.ptr);
             break;
         }
-        p = data;
         data = data->next;
-        rrd_freemem(p);
     }
+    rrd_info_free(p);
     return result;
 }