Re: [Patch] String and (repost) MemLeak
From:
Michal Rokos <michal@...>
Date:
2003-03-04 10:53:24 UTC
List:
ruby-core #913
Hi, Yukihiro Matsumoto wrote: > In message "Re: [Patch] String and (repost) MemLeak" > on 03/03/04, Michal Rokos <michal@rokos.homeip.net> writes: > > |> I consider (or designed) str_new(0, len) as allocation of string > |> buffer, so that I think garbage is OK, just like malloc(). > | > |You're probably right - if programmer wants garbage he gets it... But I > |still think that setting proper len cost nothing and could make some > |tired programmers happier. > > Cost is nothing, I agree. But if a programmer gets a zero length > string even when I specified len to str_new(), he/she may confuse > sometimes. I think it's correct - lenght is zero, but capa is correct. The reality is that string, that you created, is 0 bytes long - not X. So when you do rb_str_cat (or any other) you'll get the right* result. Michal * If you change rb_str_cat and some others as well :) PS: You may also remove MEMZERO from rb_str_cat and maybe we should test ptr in rb_str_buf_cat for NULL.