diff options
Diffstat (limited to 'ext/dl/cptr.c')
-rw-r--r-- | ext/dl/cptr.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 89dcb942c0..e60fbb48da 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -7,6 +7,15 @@ #include <ctype.h> #include "dl.h" +#ifdef PRIsVALUE +# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) +# define RB_OBJ_STRING(obj) (obj) +#else +# define PRIsVALUE "s" +# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + VALUE rb_cDLCPtr; static inline freefunc_t @@ -400,12 +409,10 @@ static VALUE rb_dlptr_inspect(VALUE self) { struct ptr_data *data; - char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data); - snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>", - rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free); - return rb_str_new2(str); + return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", + RB_OBJ_CLASSNAME(self), data, data->ptr, data->size, data->free); } /* |