[#444] io_write()/fwrite() and EINTR on Solaris — Jos Backus <jos@...>

I am encountering a problem similar to the one mentioned here,

19 messages 2002/09/06
[#453] Re: io_write()/fwrite() and EINTR on Solaris — nobu.nokada@... 2002/09/08

Hi,

[#454] Re: io_write()/fwrite() and EINTR on Solaris — matz@... (Yukihiro Matsumoto) 2002/09/09

Hi

[#469] Re: io_write()/fwrite() and EINTR on Solaris — Jos Backus <jos@...> 2002/09/09

On Mon, Sep 09, 2002 at 03:55:13PM +0900, Yukihiro Matsumoto wrote:

[#479] Re: io_write()/fwrite() and EINTR on Solaris — Jos Backus <jos@...> 2002/09/10

On Tue, Sep 10, 2002 at 01:04:10AM +0900, Jos Backus wrote:

[#492] Re: io_write()/fwrite() and EINTR on Solaris — Jos Backus <jos@...> 2002/09/21

On Wed, Sep 11, 2002 at 02:23:33AM +0900, Jos Backus wrote:

Re: [Memleak] in sprintf.c

From: Michal Rokos <m.rokos@...>
Date: 2002-09-09 10:18:24 UTC
List: ruby-core #467
Hello,

On Mon, Sep 09, 2002 at 06:58:56PM +0900, nobu.nokada@softhome.net wrote:
> > PS: Please note that it leaks when exception is raised!
> 
> It may be better to add rb_gc_force_recycle(result) at places
> where you added free(buf).

	Yes, in this case String approach is better.

	Could you commit this one, if it is OK?

		Michal
		
> Index: sprintf.c
> ===================================================================
> RCS file: /cvs/ruby/src/ruby/sprintf.c,v
> retrieving revision 1.25
> diff -u -2 -p -r1.25 sprintf.c
> --- sprintf.c	28 Aug 2002 08:05:23 -0000	1.25
> +++ sprintf.c	9 Sep 2002 09:53:24 -0000
> @@ -63,9 +63,11 @@ remove_sign_bits(str, base)
>  #define FPREC  64
>  
> -#define CHECK(l) \
> +#define CHECK(l) do {\
>      while (blen + (l) >= bsiz) {\
> -	REALLOC_N(buf, char, bsiz*2);\
>  	bsiz*=2;\
> -    }
> +    }\
> +    rb_str_resize(result, bsiz);\
> +    buf = RSTRING(result)->ptr;\
> +} while (0)
>  
>  #define PUSH(s, l) do { \
> @@ -123,5 +125,6 @@ rb_f_sprintf(argc, argv)
>      blen = 0;
>      bsiz = 120;
> -    buf = ALLOC_N(char, bsiz);
> +    result = rb_str_buf_new(bsiz);
> +    buf = RSTRING(result)->ptr;
>  
>      for (; p < end; p++) {
> @@ -580,6 +583,5 @@ rb_f_sprintf(argc, argv)
>      }
>  #endif
> -    result = rb_str_new(buf, blen);
> -    free(buf);
> +    rb_str_resize(result, blen);
>  
>      if (tainted) OBJ_TAINT(result);

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
E-mail:m.rokos@sh.cvut.cz      ICQ:36118339      Jabber:majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In This Thread

Prev Next