Boost logo

Boost :

Subject: Re: [boost] std::map::find() wrapper
From: Marsh Ray (marsh_at_[hidden])
Date: 2011-05-04 19:16:28


On 05/04/2011 04:27 PM, Nevin Liber wrote:
>
> I have a hard time imaging a useable code base which has a convention that
> any time a pointer is returned one should assume that the memory must be
> deleted by the caller.

I remember reading an article in Dr. Dobbs years ago where one of the
regular writers was reviewing some framework library. His opinion was
the opposite of yours I think. He didn't like that the framework was
handling the lifetime for him, even of its own objects. He really wanted
to see a 'delete' in his own code matching every place an object was
created dynamically.

This was before smart pointers caught on.

> You couldn't even call something as simple as
> strncat in such an environment, let alone most libraries with a C API.

Haha, most of the time programmers can't call strncat without writing a
nul-termination bug anyway. I don't think I've called strncat in my last
few hundred thousand lines of code.

I do have to work with C APIs all the time though and, you're right, it
takes *a lot* of extra care to do it correctly.

- Marsh


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk