From 15335f8aaa8282fd951935135aa04b3d938a267c Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 19 May 2010 03:12:03 +0000 Subject: * 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 --- ext/psych/emitter.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ext/psych/emitter.c') 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); -- cgit v1.2.3