fixes for ruby 1.9

This commit is contained in:
Doug MacEachern 2009-02-15 19:51:40 -08:00
parent 9835ea40c7
commit 68525d650c
1 changed files with 10 additions and 2 deletions

View File

@ -25,6 +25,14 @@
#define RB_SIGAR_CROAK rb_raise(rb_eArgError, "%s", sigar_strerror(sigar, status)) #define RB_SIGAR_CROAK rb_raise(rb_eArgError, "%s", sigar_strerror(sigar, status))
#define NUM2PID NUM2UINT #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) static sigar_t *rb_sigar_get(VALUE obj)
{ {
sigar_t *sigar; 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) 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) { switch (len) {
case 4: case 4:
@ -154,7 +162,7 @@ static int rb_sigar_str2net_address(VALUE bytes, sigar_net_address_t *address)
return EINVAL; return EINVAL;
} }
memcpy(RSTRING(bytes)->ptr, &address->addr.in6, len); memcpy(RSTRING_PTR(bytes), &address->addr.in6, len);
return SIGAR_OK; return SIGAR_OK;
} }