diff options
| author | take_cheeze <[email protected]> | 2014-08-20 22:42:35 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2014-08-20 22:42:35 +0900 |
| commit | b3d0585fe5e437633e13c12029d715721ab3a3e5 (patch) | |
| tree | a67825797db6fdd20742ac8e654ef378b49c9d54 /mrbgems/mruby-time | |
| parent | f6f31a8ecd7e8f9f9830f050842e11d2aaef94a1 (diff) | |
| download | mruby-b3d0585fe5e437633e13c12029d715721ab3a3e5.tar.gz mruby-b3d0585fe5e437633e13c12029d715721ab3a3e5.zip | |
Add API `mrb_data_init` to initialize `MRB_TT_DATA` tagged instance.
Diffstat (limited to 'mrbgems/mruby-time')
| -rw-r--r-- | mrbgems/mruby-time/src/time.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index 009c01acb..00c8387b2 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -561,8 +561,7 @@ mrb_time_initialize(mrb_state *mrb, mrb_value self) if (tm) { mrb_free(mrb, tm); } - DATA_TYPE(self) = &mrb_time_type; - DATA_PTR(self) = NULL; + mrb_data_init(self, NULL, &mrb_time_type); n = mrb_get_args(mrb, "|iiiiiii", &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec); @@ -572,7 +571,7 @@ mrb_time_initialize(mrb_state *mrb, mrb_value self) else { tm = time_mktime(mrb, ayear, amonth, aday, ahour, amin, asec, ausec, MRB_TIMEZONE_LOCAL); } - DATA_PTR(self) = tm; + mrb_data_init(self, tm, &mrb_time_type); return self; } @@ -589,8 +588,7 @@ mrb_time_initialize_copy(mrb_state *mrb, mrb_value copy) mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class"); } if (!DATA_PTR(copy)) { - DATA_PTR(copy) = mrb_malloc(mrb, sizeof(struct mrb_time)); - DATA_TYPE(copy) = &mrb_time_type; + mrb_data_init(copy, mrb_malloc(mrb, sizeof(struct mrb_time)), &mrb_time_type); } *(struct mrb_time *)DATA_PTR(copy) = *(struct mrb_time *)DATA_PTR(src); return copy; |
