summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/psych_emitter.c5
-rw-r--r--ext/psych/psych_parser.c4
2 files changed, 4 insertions, 5 deletions
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index 4ba238102b..feffc54ce7 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -50,14 +50,13 @@ static const rb_data_type_t psych_emitter_type = {
static VALUE allocate(VALUE klass)
{
yaml_emitter_t * emitter;
-
- emitter = xmalloc(sizeof(yaml_emitter_t));
+ VALUE obj = TypedData_Make_Struct(klass, yaml_emitter_t, &psych_emitter_type, emitter);
yaml_emitter_initialize(emitter);
yaml_emitter_set_unicode(emitter, 1);
yaml_emitter_set_indent(emitter, 2);
- return TypedData_Wrap_Struct(klass, &psych_emitter_type, emitter);
+ return obj;
}
/* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c
index faae460dd0..2caa8a09c3 100644
--- a/ext/psych/psych_parser.c
+++ b/ext/psych/psych_parser.c
@@ -70,11 +70,11 @@ static const rb_data_type_t psych_parser_type = {
static VALUE allocate(VALUE klass)
{
yaml_parser_t * parser;
+ VALUE obj = TypedData_Make_Struct(klass, yaml_parser_t, &psych_parser_type, parser);
- parser = xmalloc(sizeof(yaml_parser_t));
yaml_parser_initialize(parser);
- return TypedData_Wrap_Struct(klass, &psych_parser_type, parser);
+ return obj;
}
static VALUE make_exception(yaml_parser_t * parser, VALUE path)