From 68525d650c88d7ea2acfe51805558392143c0660 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 15 Feb 2009 19:51:40 -0800 Subject: [PATCH] fixes for ruby 1.9 --- bindings/ruby/rbsigar.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index 42d14b86..dde9a78e 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -25,6 +25,14 @@ #define RB_SIGAR_CROAK rb_raise(rb_eArgError, "%s", sigar_strerror(sigar, status)) #define NUM2PID NUM2UINT +#ifndef RSTRING_PTR +#define RSTRING_PTR(s) (s)->ptr +#endif + +#ifndef RSTRING_LEN +#define RSTRING_LEN(s) (s)->len +#endif + static sigar_t *rb_sigar_get(VALUE obj) { sigar_t *sigar; @@ -141,7 +149,7 @@ static VALUE rb_sigar_net_interface_list(VALUE obj) static int rb_sigar_str2net_address(VALUE bytes, sigar_net_address_t *address) { - long len = RSTRING(bytes)->len; + long len = RSTRING_LEN(bytes); switch (len) { case 4: @@ -154,7 +162,7 @@ static int rb_sigar_str2net_address(VALUE bytes, sigar_net_address_t *address) return EINVAL; } - memcpy(RSTRING(bytes)->ptr, &address->addr.in6, len); + memcpy(RSTRING_PTR(bytes), &address->addr.in6, len); return SIGAR_OK; }