summaryrefslogtreecommitdiff
path: root/ext/zlib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-01 00:35:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-01 00:35:00 +0000
commit5f8ae91717e26dee100cfba510b6db34d9c8add2 (patch)
tree49ff82b18d49e40c30a8436d6a3566428585e2eb /ext/zlib
parentfbb38d6d6afe264da33bbff0156dc21eb7cd6b36 (diff)
zlib.c: zstream_expand_buffer_non_stream
* ext/zlib/zlib.c (zstream_expand_buffer_non_stream): rename from zstream_expand_buffer_without_gvl() and replace duplicate code in zstream_expand_buffer(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/zlib.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 516f62c..096218b 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -72,6 +72,7 @@ struct zstream_run_args;
static void zstream_init(struct zstream*, const struct zstream_funcs*);
static void zstream_expand_buffer(struct zstream*);
static void zstream_expand_buffer_into(struct zstream*, unsigned long);
+static int zstream_expand_buffer_non_stream(struct zstream *z);
static void zstream_append_buffer(struct zstream*, const Bytef*, long);
static VALUE zstream_detach_buffer(struct zstream*);
static VALUE zstream_shift_buffer(struct zstream*, long);
@@ -648,19 +649,7 @@ zstream_expand_buffer(struct zstream *z)
}
}
else {
- if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
- z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
- }
- else {
- long inc = z->buf_filled / 2;
- if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
- inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
- }
- rb_str_resize(z->buf, z->buf_filled + inc);
- z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
- (int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
- }
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ zstream_expand_buffer_non_stream(z);
}
}
@@ -695,7 +684,7 @@ zstream_expand_buffer_protect(void *ptr)
}
static int
-zstream_expand_buffer_without_gvl(struct zstream *z)
+zstream_expand_buffer_non_stream(struct zstream *z)
{
char * new_str;
long inc, len;
@@ -997,7 +986,7 @@ zstream_run_func(void *ptr)
(void *)z);
}
else {
- state = zstream_expand_buffer_without_gvl(z);
+ state = zstream_expand_buffer_non_stream(z);
}
if (state) {