Blob Blame Raw
--- rubyrrdtool.c.orig	2012-02-29 10:43:56.000000000 +0100
+++ rubyrrdtool.c	2012-02-29 10:46:06.992914897 +0100
@@ -94,7 +94,7 @@
     Check_Type(strs, T_ARRAY);
     
     /* set the array length */
-    a.len = RARRAY(strs)->len;
+    a.len = RARRAY_LEN(strs);
     if (name_f)  {  a.len++; }
     if (dummy_f) {  a.len++; }
     a.strs = ALLOC_N(char*, a.len);
@@ -115,7 +115,7 @@
     
     /* add the rrdname if needed */
     if (name_f) {
-        a.strs[i] = strdup(STR2CSTR(rrd));
+        a.strs[i] = strdup(StringValueCStr(rrd));
         i++;
     }
     
@@ -302,7 +302,7 @@
     pdp_step = NUM2LONG(ostep);
     last_up  = (time_t)NUM2LONG(update);
 #ifdef R_RRD_DBG    
-    snprintf(buf, NUM_BUF_SZ, "n=[%s] : step=%lu : up=%ld", STR2CSTR(rrd),
+    snprintf(buf, NUM_BUF_SZ, "n=[%s] : step=%lu : up=%ld", StringValueCStr(rrd),
              pdp_step, (long int)last_up);
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
@@ -313,7 +313,7 @@
 #endif
     
     /* now run the command */
-    result = rrd_create_r(STR2CSTR(rrd), pdp_step, last_up, a.len, a.strs);
+    result = rrd_create_r(StringValueCStr(rrd), pdp_step, last_up, a.len, a.strs);
 
 #ifdef R_RRD_DBG
     _dbug(R_RRD_DEBUG_SIM, "cleanup");
@@ -368,7 +368,7 @@
     /* type checking */
     Check_Type(output, T_STRING);
     
-    ret = rrd_dump_r(STR2CSTR(rrd), STR2CSTR(output));
+    ret = rrd_dump_r(StringValueCStr(rrd), StringValueCStr(output));
     if (ret == -1) {
         RRD_RAISE;
         rval = Qnil;
@@ -413,7 +413,7 @@
         idx = NUM2INT(orra_idx);
     }
     
-    when = rrd_first_r(STR2CSTR(rrd), idx);
+    when = rrd_first_r(StringValueCStr(rrd), idx);
     if (when == -1) {
         RRD_RAISE;
         rval = Qnil;
@@ -423,7 +423,7 @@
     
 #ifdef R_RRD_DBG    
     snprintf(buf, NUM_BUF_SZ, "first: rrd=[%s] : idx=%d : val=%ld",
-             STR2CSTR(rrd), idx, when);
+             StringValueCStr(rrd), idx, when);
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
 #endif
@@ -456,7 +456,7 @@
     
     rrd = rb_iv_get(self, "@rrdname");
     
-    when = rrd_last_r(STR2CSTR(rrd));
+    when = rrd_last_r(StringValueCStr(rrd));
     if (when == -1) {
         RRD_RAISE;
         rval = Qnil;
@@ -465,7 +465,7 @@
     }
     
 #ifdef R_RRD_DBG    
-    snprintf(buf, NUM_BUF_SZ, "last: rrd=[%s] : val=%ld", STR2CSTR(rrd), when);
+    snprintf(buf, NUM_BUF_SZ, "last: rrd=[%s] : val=%ld", StringValueCStr(rrd), when);
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
 #endif
@@ -579,14 +579,14 @@
     tmpl = StringValue(otemp);
     
 #ifdef R_RRD_DBG    
-    snprintf(buf, NUM_BUF_SZ, "n=[%s] : tmpl=%s", STR2CSTR(rrd), STR2CSTR(tmpl));
+    snprintf(buf, NUM_BUF_SZ, "n=[%s] : tmpl=%s", StringValueCStr(rrd), StringValueCStr(tmpl));
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
 #endif
     a = s_arr_new(self, false, false, args);
     
     /* now run the command */
-    result = rrd_update_r(STR2CSTR(rrd), STR2CSTR(tmpl), a.len, a.strs);
+    result = rrd_update_r(StringValueCStr(rrd), StringValueCStr(tmpl), a.len, a.strs);
     /* cleanup */
     s_arr_del(a);
 
@@ -717,14 +717,14 @@
     
 #ifdef R_RRD_DBG    
     snprintf(buf, NUM_BUF_SZ, "restore: xml=%s rrd=%s",
-             STR2CSTR(xml), STR2CSTR(rrd));
+             StringValueCStr(xml), StringValueCStr(rrd));
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
 #endif
     a = s_arr_new(self, false, false, args);
-    s_arr_push(STR2CSTR(rrd), &a);
-    s_arr_push(STR2CSTR(xml), &a);
-    s_arr_push(STR2CSTR(xml), &a);
+    s_arr_push(StringValueCStr(rrd), &a);
+    s_arr_push(StringValueCStr(xml), &a);
+    s_arr_push(StringValueCStr(xml), &a);
     
     /* now run the command */
     result = rrd_restore(a.len, a.strs);
@@ -998,7 +998,7 @@
     reset_rrd_state();
     
     rrd = rb_iv_get(self, "@rrdname");
-    data = rrd_info_r(STR2CSTR(rrd));
+    data = rrd_info_r(StringValueCStr(rrd));
 
     RRD_CHECK_ERROR;
 
@@ -1054,7 +1054,7 @@
     rrdname = StringValue(ofname);
     rb_iv_set(self, "@rrdname", rrdname);
 #ifdef R_RRD_DBG    
-    snprintf(buf, NUM_BUF_SZ, "rrdname=[%s]", STR2CSTR(rrdname));
+    snprintf(buf, NUM_BUF_SZ, "rrdname=[%s]", StringValueCStr(rrdname));
     buf[NUM_BUF_SZ] = 0;
     _dbug(R_RRD_DEBUG_SIM, buf);
 #endif