Re: [PATCH] HttpBody refactoring

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 07 Dec 2011 17:26:28 -0700

On 12/03/2011 03:13 PM, Kinkie wrote:
> Hi all,
> yet another struct-turned-class.
> It is more or less a straightforward porting, with minimal interface
> extensions aimed at keeping the MemBuf data-member private.
> For simplicity's sake I've added one invariant condition: during a
> HttpBody lifetime, the MemBuf data member is never NULL.
>
> Please review

> +HttpBody::~HttpBody()
> {
> - body->mb = new MemBuf;
> + clear();
> + delete mb;
> }

Calling clear() in the destructor seems to be just adding [minor]
overhead and a [remote] possibility of hitting a !stolen assertion in
some future code. Delete alone is sufficient.

> +HttpBody::clear()
> {
> + if(!mb->isNull())
> + mb->clean();
> }

The NULL check should be removed in modern code. MemBuf::clean can
handle nil buffers.

> +HttpBody::setMb(MemBuf * mb_)
> {
> + clear();
> + delete mb;
> + mb = mb_; /* absorb */
> }

Same thing here. No need to clear() before deleting.

Thank you,

Alex.
Received on Thu Dec 08 2011 - 00:27:11 MST

This archive was generated by hypermail 2.2.0 : Fri Dec 09 2011 - 12:00:09 MST