summaryrefslogtreecommitdiff
path: root/ext/syck/rubyext.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/syck/rubyext.c')
-rw-r--r--ext/syck/rubyext.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 272cfd2..f75e3ca 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -115,14 +115,15 @@ rb_syck_compile(self, port)
oid = syck_parse( parser );
syck_lookup_sym( parser, oid, (char **)&sav );
- ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 );
+ bc = rb_str_new(0, strlen( sav->buffer ) + 3);
+ ret = RSTRING(bc)->ptr;
ret[0] = '\0';
strcat( ret, "D\n" );
strcat( ret, sav->buffer );
syck_free_parser( parser );
- bc = rb_str_new2( ret ); S_FREE( ret );
+ rb_str_resize( bc, strlen(ret) );
if ( taint ) OBJ_TAINT( bc );
return bc;
}
@@ -1042,13 +1043,13 @@ syck_set_ivars( vars, obj )
{
VALUE ivname = rb_ary_entry( vars, 0 );
char *ivn;
+ ID ivns;
StringValue( ivname );
ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 );
- ivn[0] = '@';
- ivn[1] = '\0';
- strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len );
- rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
+ snprintf(ivn, RSTRING(ivname)->len + 1, "@%s", RSTRING(ivname)->ptr);
+ ivns = rb_intern(ivn);
S_FREE( ivn );
+ rb_ivar_set( obj, ivns, rb_ary_entry( vars, 1 ) );
return Qnil;
}