From 23c95ef6c7c283bca8e3b2b8e670ec99ef07ca32 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 9 Sep 2009 03:01:37 +0000 Subject: [PATCH] * file.c (stat_data_type): typed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++- file.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81d5da3733..5fff6d1254 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Wed Sep 9 11:55:07 2009 Nobuyoshi Nakada +Wed Sep 9 12:01:36 2009 Nobuyoshi Nakada * dir.c (dir_data_type): typed. @@ -7,6 +7,8 @@ Wed Sep 9 11:55:07 2009 Nobuyoshi Nakada * error.c (name_err_mesg_data_type): typed. + * file.c (stat_data_type): typed. + Wed Sep 9 11:11:33 2009 Nobuyoshi Nakada * include/ruby/ruby.h (rb_data_type_struct): constified dsize. diff --git a/file.c b/file.c index a212668f95..b872002c2f 100644 --- a/file.c +++ b/file.c @@ -180,6 +180,17 @@ rb_file_path(VALUE obj) return rb_obj_taint(rb_str_dup(fptr->pathv)); } +static size_t +stat_memsize(const void *p) +{ + return p ? sizeof(struct stat) : 0; +} + +static const rb_data_type_t stat_data_type = { + "stat", + NULL, RUBY_TYPED_DEFAULT_FREE, stat_memsize, +}; + static VALUE stat_new_0(VALUE klass, struct stat *st) { @@ -189,7 +200,7 @@ stat_new_0(VALUE klass, struct stat *st) nst = ALLOC(struct stat); *nst = *st; } - return Data_Wrap_Struct(klass, NULL, -1, nst); + return TypedData_Wrap_Struct(klass, &stat_data_type, nst); } static VALUE @@ -202,7 +213,7 @@ static struct stat* get_stat(VALUE self) { struct stat* st; - Data_Get_Struct(self, struct stat, st); + TypedData_Get_Struct(self, struct stat, &stat_data_type, st); if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat"); return st; } @@ -679,7 +690,7 @@ rb_stat_inspect(VALUE self) }; struct stat* st; - Data_Get_Struct(self, struct stat, st); + TypedData_Get_Struct(self, struct stat, &stat_data_type, st); if (!st) { return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self)); }