projects
/
ruby-vorbistagger.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made the IO buffer global.
[ruby-vorbistagger.git]
/
ext
/
ext.c
diff --git
a/ext/ext.c
b/ext/ext.c
index 4794d282dca70b4a66d20321a1eb24e9a7be2c45..99eefbe9ba5ef6ff6684e45c97a7aea6b5c5790e 100644
(file)
--- a/
ext/ext.c
+++ b/
ext/ext.c
@@
-29,12
+29,11
@@
typedef struct {
vcedit_state *state;
VALUE comments;
vcedit_state *state;
VALUE comments;
- VALUE io_buf;
} RbVorbisTagger;
static VALUE c_close (VALUE self);
} RbVorbisTagger;
static VALUE c_close (VALUE self);
-static VALUE cComments, eVTError;
+static VALUE cComments, eVTError
, io_buf
;
static ID id_read, id_write, id_seek, id_length;
static size_t
static ID id_read, id_write, id_seek, id_length;
static size_t
@@
-44,9
+43,9
@@
on_read (void *ptr, size_t size, size_t nmemb, RbVorbisTagger *o)
size_t total = size * nmemb;
VALUE tmp;
size_t total = size * nmemb;
VALUE tmp;
- rb_str_resize (
o->
io_buf, size * nmemb);
+ rb_str_resize (io_buf, size * nmemb);
- tmp = rb_funcall (o->io, id_read, 2, LONG2NUM (total),
o->
io_buf);
+ tmp = rb_funcall (o->io, id_read, 2, LONG2NUM (total), io_buf);
if (NIL_P (tmp))
return 0;
if (NIL_P (tmp))
return 0;
@@
-61,10
+60,10
@@
on_write (const void *ptr, size_t size, size_t nmemb, RbVorbisTagger *o)
{
size_t total = size * nmemb;
{
size_t total = size * nmemb;
- rb_str_resize (
o->
io_buf, total);
- memcpy (RSTRING (
o->
io_buf)->ptr, ptr, total);
+ rb_str_resize (io_buf, total);
+ memcpy (RSTRING (io_buf)->ptr, ptr, total);
- return NUM2LONG (rb_io_write (o->io,
o->
io_buf));
+ return NUM2LONG (rb_io_write (o->io, io_buf));
}
static void
}
static void
@@
-72,7
+71,7
@@
c_mark (RbVorbisTagger *o)
{
rb_gc_mark (o->io);
rb_gc_mark (o->comments);
{
rb_gc_mark (o->io);
rb_gc_mark (o->comments);
- rb_gc_mark (
o->
io_buf);
+ rb_gc_mark (io_buf);
}
static void
}
static void
@@
-146,7
+145,6
@@
c_init (VALUE self, VALUE io)
rb_raise (rb_eArgError, "invalid argument");
o->io = io;
rb_raise (rb_eArgError, "invalid argument");
o->io = io;
- o->io_buf = rb_str_buf_new (BUFSIZ);
o->state = vcedit_state_new ();
if (!o->state)
o->state = vcedit_state_new ();
if (!o->state)
@@
-278,4
+276,7
@@
Init_vorbistagger_ext (void)
id_length = rb_intern ("length");
cComments = Init_Comments (mVorbis);
id_length = rb_intern ("length");
cComments = Init_Comments (mVorbis);
+
+ io_buf = rb_str_buf_new (BUFSIZ);
+ rb_global_variable (&io_buf);
}
}