summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-09 03:01:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-09 03:01:37 +0000
commit23c95ef6c7c283bca8e3b2b8e670ec99ef07ca32 (patch)
treeee5c29067d333789322732406e68d729e417aa77 /file.c
parent355047fb4948d00c4e3cd6cdcc8c8a52368673d2 (diff)
downloadruby-23c95ef6c7c283bca8e3b2b8e670ec99ef07ca32.tar.gz
* file.c (stat_data_type): typed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c17
1 files changed, 14 insertions, 3 deletions
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));
}