Re: RFC: (in head) Throws()?

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Tue, 14 Oct 2008 00:26:53 +1300

Kinkie wrote:
> Hi all.
>
> I've recently found myself battlign with a certain difficulty in
> formatting custom messages for thrown exceptions; in order to use
> TextExceptions properly I'd have to set a stringstream up, fill it in,
> get a c_str out and then Throw, leaking memory in the meantime because
> the message would be double-copied and there'd be no reachable code to
> free one of the copies. The current Throw() implementation is very
> skewed towards servicing Must().
>
> All of this should be easily solvable by defining a Throws() macro
> (possibly with an accompanying Musts call) which would offer semantics
> similar to debugs(), and get rid of this wart in one easy sweep.
>
> Any opinions?
>

Um I don't see what your problem is. Or what you are trying to do.

To me it looks like is highly geared around non-dependable char* and
Must() is warped to fit TextException.

"TextException::TextException(msg)"
   can take a local char buffer[], "constant string", or object.c_buf().
   it does xstrdup() and xfree() it properly on its own.

Amos

-- 
Please use Squid 2.7.STABLE4 or 3.0.STABLE9
Received on Mon Oct 13 2008 - 11:26:56 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 13 2008 - 12:00:03 MDT