incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicole Willson" <will...@roguewave.com>
Subject RE: problem in temp_buffer
Date Tue, 25 Jul 2006 18:04:04 GMT
Well, I just ran the testcase in the bug without issue - so that's not
the exact problem.
 

-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Tuesday, July 25, 2006 11:38 AM
To: stdcxx-dev@incubator.apache.org
Subject: Re: problem in temp_buffer

Nicole Willson wrote:
> I just noticed that it isn't ignored, but I still don't understand the

> purpose.

_RWSTD_TMPBUF_SIZE is #defined to the size of the static temporary
buffer. When get_temporary_buffer() is invoked to request a buffer whose
size in bytes is less than or equal to _RWSTD_TMPBUF_SIZE and the static
buffer is not in use yet the function returns the address of the buffer
to the caller. Otherwise it tries to allocate the buffer dynamically on
the heap. If the allocation fails,
get_temporary_buffer() fails by returning pair(0, 0).


> If the check fails, it simply procedes to __rw_allocate.
> Since the code I am tracking has sent in a block so large that the 
> code will not be able to address it all, I would think it would stop
here.
> Is __rw_allocate supposed to handle this?

__rw_allocate() is just a wrapper around operator new. It throws an
exception on failure. __rw_tmpbuf() catches it and returns pair(0, 0)
instead.

What exactly is the issue you are tracking down? Some compilers are
known to fail the test (with various symptoms) due to a bug.
See, for example
http://bugzilla.cvo.roguewave.com/show_bug.cgi?id=1605

Martin

> 
> -----Original Message-----
> From: Nicole Willson [mailto:willson@roguewave.com]
> Sent: Tuesday, July 25, 2006 11:15 AM
> To: Stdcxx
> Subject: RE: problem in temp_buffer
> 
> I'm tracking down an issue with temp_buffer in stdlib/utilities.  I'm 
> confused by a piece of code in source/stdlib/tmpbuf.cpp:
>  
> if (nbytes <= _RWSTD_TMPBUF_SIZE) {
>  
>         if (1 == _RWSTD_THREAD_PREINCREMENT (__rw_buffer_busy, false))

> {
>  
>             *pptr = buffer;
>  
>             // static buffer used, its usage counter stays non-zero
>             return _RWSTD_TMPBUF_SIZE / size;
>         }
>  
>         // static buffer not used, decrement its usage counter
>         _RWSTD_THREAD_PREDECREMENT (__rw_buffer_busy, false);
>     }
>  
>     _TRY {
>         *pptr = __rw_allocate (nbytes, 0);
>     }
>     _CATCH (...) {
>         *pptr  = 0;
>         nbytes = 0;
>     }
>  
>     return nbytes / size;
> 
>  
> What is the purpose of the check against _RWSTD_TMPBUF_SIZE if it is 
> ignored?
> 
> Nicole Willson
> 
> Consulting Engineer
> 
> Rogue Wave Software, Inc.
> 
> A Division of Quovadx
> 
> 303-545-3210
> 
>  
> 


Mime
View raw message