diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-08-06 15:05:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-08-06 15:05:50 +0000 |
commit | eccd4f15ff05f44e2ca0670ef656da1eff560b28 (patch) | |
tree | 15776a8c73c6544e48a7e51d3ffed80c69635267 /pack.c | |
parent | be5c75c94d6b2ce082e16bd1609cfefa15d0262a (diff) | |
download | ruby-eccd4f15ff05f44e2ca0670ef656da1eff560b28.tar.gz ruby-eccd4f15ff05f44e2ca0670ef656da1eff560b28.tar.xz ruby-eccd4f15ff05f44e2ca0670ef656da1eff560b28.zip |
a problem about `associated' String and `str_buf'.
* pack.c (pack_unpack): associates p/P strings once at
last(reverted to 1.26).
* string.c (rb_str_associate): associates an Array at once, not
but a String. realloc's when str_buf.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -331,7 +331,7 @@ pack_pack(ary, fmt) static char *nul10 = "\0\0\0\0\0\0\0\0\0\0"; static char *spc10 = " "; char *p, *pend; - VALUE res, from; + VALUE res, from, associates = 0; char type; int items, len, idx; char *ptr; @@ -872,7 +872,10 @@ pack_pack(ary, fmt) StringValue(from); t = RSTRING(from)->ptr; } - rb_str_associate(res, from); + if (!associates) { + associates = rb_ary_new(); + } + rb_ary_push(associates, from); rb_str_buf_cat(res, (char*)&t, sizeof(char*)); } break; @@ -927,6 +930,10 @@ pack_pack(ary, fmt) break; } } + + if (associates) { + rb_str_associate(res, associates); + } return res; } |