summaryrefslogtreecommitdiff
path: root/ext/psych/emitter.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 03:12:03 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 03:12:03 +0000
commit15335f8aaa8282fd951935135aa04b3d938a267c (patch)
treedd5eabbc54d17c2454dddb00136bb684ee85cd33 /ext/psych/emitter.c
parenta8f8b617c0c609557c80f85de59a4472cc5d45d5 (diff)
* ext/psych/emitter.c: using xmalloc and xfree for memory allocation
* ext/psych/lib/psych/nodes/stream.rb: encoding should be read / write * ext/psych/parser.c: supporting UTF-16 and UTF-16 + BOM * test/psych/test_parser.rb: testing UTF-16 and UTF-16 + BOM git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/emitter.c')
-rw-r--r--ext/psych/emitter.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/psych/emitter.c b/ext/psych/emitter.c
index befa98e821..a06304aba6 100644
--- a/ext/psych/emitter.c
+++ b/ext/psych/emitter.c
@@ -17,15 +17,21 @@ static int writer(void *ctx, unsigned char *buffer, size_t size)
return (int)NUM2INT(wrote);
}
-static void dealloc(yaml_emitter_t * emitter)
+static void dealloc(void * ptr)
{
+ yaml_emitter_t * emitter;
+
+ emitter = (yaml_emitter_t *)ptr;
yaml_emitter_delete(emitter);
- free(emitter);
+ xfree(emitter);
}
static VALUE allocate(VALUE klass)
{
- yaml_emitter_t * emitter = malloc(sizeof(yaml_emitter_t));
+ yaml_emitter_t * emitter;
+
+ emitter = xmalloc(sizeof(yaml_emitter_t));
+
yaml_emitter_initialize(emitter);
yaml_emitter_set_unicode(emitter, 1);
yaml_emitter_set_indent(emitter, 2);