diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-01 00:35:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-01 00:35:02 +0000 |
commit | c4c3d86a1fa66eb84ecf38c5a63c5b486755f7b1 (patch) | |
tree | 6bba2e32b0b37a0e4f1f12d3ac51cc3f99700240 /ext/zlib/zlib.c | |
parent | 5f8ae91717e26dee100cfba510b6db34d9c8add2 (diff) | |
download | ruby-c4c3d86a1fa66eb84ecf38c5a63c5b486755f7b1.tar.gz |
zlib.c: zstream_buffer_ungetbyte
* ext/zlib/zlib.c (zstream_buffer_ungetbyte): simplify by using
zstream_buffer_ungets().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r-- | ext/zlib/zlib.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 096218b496..64a480cfed 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -829,17 +829,8 @@ zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len) static void zstream_buffer_ungetbyte(struct zstream *z, int c) { - if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) { - zstream_expand_buffer(z); - } - - memmove(RSTRING_PTR(z->buf) + 1, RSTRING_PTR(z->buf), z->buf_filled); - RSTRING_PTR(z->buf)[0] = (char)c; - z->buf_filled++; - if (z->stream.avail_out > 0) { - z->stream.next_out++; - z->stream.avail_out--; - } + Bytef cc = (Bytef)c; + zstream_buffer_ungets(z, &cc, 1); } static void |