about summary refs log tree commit homepage
path: root/ext/posix_mq/posix_mq.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/posix_mq/posix_mq.c')
-rw-r--r--ext/posix_mq/posix_mq.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 55ec51e..83e9e58 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -317,11 +317,22 @@ static void _free(void *ptr)
         xfree(ptr);
 }
 
+static size_t memsize(const void *ptr)
+{
+        return sizeof(struct posix_mq);
+}
+
+static const rb_data_type_t mqtype = {
+        "posix_mq",
+        { mark, _free, memsize, /* reserved */ },
+        /* parent, data, [ flags ] */
+};
+
 /* automatically called at creation (before initialize) */
 static VALUE alloc(VALUE klass)
 {
         struct posix_mq *mq;
-        VALUE rv = Data_Make_Struct(klass, struct posix_mq, mark, _free, mq);
+        VALUE rv = TypedData_Make_Struct(klass, struct posix_mq, &mqtype, mq);
 
         mq->des = MQD_INVALID;
         mq->autoclose = 1;
@@ -341,7 +352,7 @@ static struct posix_mq *get(VALUE self, int need_valid)
 {
         struct posix_mq *mq;
 
-        Data_Get_Struct(self, struct posix_mq, mq);
+        TypedData_Get_Struct(self, struct posix_mq, &mqtype, mq);
 
         if (need_valid && mq->des == MQD_INVALID)
                 rb_raise(rb_eIOError, "closed queue descriptor");