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.

Reply via email to