diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-16 22:36:27 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-16 22:36:27 +0000 |
commit | 3caa4ee5e545ee975ca3dc3fa798e63876e59a05 (patch) | |
tree | c15c43e94c7e82c7260cf9d175919511e0dc0786 /transcode.c | |
parent | 51d174a17704c56342488cc1cc932b0825a3f305 (diff) | |
download | ruby-3caa4ee5e545ee975ca3dc3fa798e63876e59a05.tar.gz |
* array.c (rb_ary_memsize): added.
* io.c (rb_io_memsize): added.
* regcomp.c (onig_memsize): added.
* string.c (rb_str_memsize): added.
* transcode.c (rb_transcoding_memsize, rb_econv_memsize): added.
* variable.c (rb_geneic_ivar_memsize): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r-- | transcode.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/transcode.c b/transcode.c index 524ea660dc..7fb25601fc 100644 --- a/transcode.c +++ b/transcode.c @@ -798,6 +798,24 @@ rb_transcoding_close(rb_transcoding *tc) xfree(tc); } +static size_t +rb_transcoding_memsize(rb_transcoding *tc) +{ + size_t size = sizeof(rb_transcoding); + const rb_transcoder *tr = tc->transcoder; + + if (TRANSCODING_STATE_EMBED_MAX < tr->state_size) { + size += tr->state_size; + } + if (sizeof(tc->readbuf.ary) < tr->max_input) { + size += tr->max_input; + } + if (sizeof(tc->writebuf.ary) < tr->max_output) { + size += tr->max_output; + } + return size; +} + static rb_econv_t * rb_econv_alloc(int n_hint) { @@ -1663,6 +1681,28 @@ rb_econv_close(rb_econv_t *ec) xfree(ec); } +size_t +rb_econv_memsize(rb_econv_t *ec) +{ + size_t size = sizeof(rb_econv_t); + int i; + + if (ec->replacement_allocated) { + size += ec->replacement_len; + } + for (i = 0; i < ec->num_trans; i++) { + size += rb_transcoding_memsize(ec->elems[i].tc); + + if (ec->elems[i].out_buf_start) { + size += ec->elems[i].out_buf_end - ec->elems[i].out_buf_start; + } + } + size += ec->in_buf_end - ec->in_buf_start; + size += sizeof(rb_econv_elem_t) * ec->num_allocated; + + return size; +} + int rb_econv_putbackable(rb_econv_t *ec) { |