X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=ext%2Fcomments.c;h=fb3ae82f653d727d751cc9975626caabfb1b5f8c;hb=de09557fdbeb5648cc66ea5fca28b3d769003ee8;hp=f7919dbdac1e20219a8a45dd70d79a1361aa5f95;hpb=0ce138263f8bea54e13953167bb1c82794506d02;p=ruby-vorbistagger.git diff --git a/ext/comments.c b/ext/comments.c index f7919db..fb3ae82 100644 --- a/ext/comments.c +++ b/ext/comments.c @@ -35,8 +35,8 @@ comments_init (VALUE self, vcedit_state *state) vc = vcedit_comments (state); - items = rb_ary_new2 (vc->comments); - rb_iv_set (self, "items", items); + items = rb_iv_get (self, "items"); + rb_ary_clear (items); for (i = 0; i < vc->comments; i++) { VALUE k, v, pair; @@ -79,6 +79,19 @@ comments_sync (VALUE self, vcedit_state *state) StringValuePtr (pair->ptr[1])); } } +/* + * call-seq: + * Ogg::Vorbis::Comments.new -> object + * + * Creates an Ogg::Vorbis::Comments object. + */ +static VALUE +c_init (VALUE self) +{ + rb_iv_set (self, "items", rb_ary_new ()); + + return self; +} /* * call-seq: @@ -493,6 +506,7 @@ Init_Comments (VALUE mVorbis) c = rb_define_class_under (mVorbis, "Comments", rb_cObject); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "inspect", c_inspect, 0); rb_define_method (c, "clear", c_clear, 0); rb_define_method (c, "delete", c_delete, 1);