summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/digest/digest.c5
-rw-r--r--ext/strscan/strscan.c4
-rw-r--r--parse.y24
-rw-r--r--variable.c3
4 files changed, 12 insertions, 24 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index ed96c2f..239fe7c 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -565,11 +565,10 @@ rb_digest_base_alloc(VALUE klass)
algo = get_digest_base_metadata(klass);
- pctx = xmalloc(algo->ctx_size);
+ obj = rb_data_typed_object_zalloc(klass, algo->ctx_size, &digest_type);
+ pctx = RTYPEDDATA_DATA(obj);
algo_init(algo, pctx);
- obj = TypedData_Wrap_Struct(klass, &digest_type, pctx);
-
return obj;
}
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 55d13d4..a0a015b 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -198,12 +198,12 @@ static VALUE
strscan_s_allocate(VALUE klass)
{
struct strscanner *p;
+ VALUE obj = TypedData_Make_Struct(klass, struct strscanner, &strscanner_type, p);
- p = ZALLOC(struct strscanner);
CLEAR_MATCH_STATUS(p);
onig_region_init(&(p->regs));
p->str = Qnil;
- return TypedData_Wrap_Struct(klass, &strscanner_type, p);
+ return obj;
}
/*
diff --git a/parse.y b/parse.y
index 54850e7..36845b4 100644
--- a/parse.y
+++ b/parse.y
@@ -10659,22 +10659,14 @@ rb_reserved_word(const char *str, unsigned int len)
return reserved_word(str, len);
}
-static struct parser_params *
-parser_new(void)
-{
- struct parser_params *p;
-
- p = ZALLOC(struct parser_params);
- parser_initialize(p);
- return p;
-}
-
VALUE
rb_parser_new(void)
{
- struct parser_params *p = parser_new();
-
- return TypedData_Wrap_Struct(0, &parser_data_type, p);
+ struct parser_params *p;
+ VALUE parser = TypedData_Make_Struct(0, struct parser_params,
+ &parser_data_type, p);
+ parser_initialize(p);
+ return parser;
}
#endif
@@ -11124,10 +11116,8 @@ static VALUE
ripper_s_allocate(VALUE klass)
{
struct parser_params *p;
- VALUE self;
-
- p = ZALLOC(struct parser_params);
- self = TypedData_Wrap_Struct(klass, &parser_data_type, p);
+ VALUE self = TypedData_Make_Struct(klass, struct parser_params,
+ &parser_data_type, p);
p->value = self;
return self;
}
diff --git a/variable.c b/variable.c
index 9b5a326..8514c5e 100644
--- a/variable.c
+++ b/variable.c
@@ -1682,12 +1682,11 @@ rb_autoload(VALUE mod, ID id, const char *file)
FL_UNSET(fn, FL_TAINT);
OBJ_FREEZE(fn);
- ele = ALLOC(struct autoload_data_i);
+ ad = TypedData_Make_Struct(0, struct autoload_data_i, &autoload_data_i_type, ele);
ele->feature = fn;
ele->safe_level = rb_safe_level();
ele->thread = Qnil;
ele->value = Qundef;
- ad = TypedData_Wrap_Struct(0, &autoload_data_i_type, ele);
st_insert(tbl, (st_data_t)id, (st_data_t)ad);
}