Re: Commit: Re: patch: one-liner for 1134

Subject: Re: Commit: Re: patch: one-liner for 1134
From: Patrick Lam (
Date: Fri Mar 30 2001 - 14:14:36 CST

On 30 Mar 2001, Joaquin Cuenca Abela wrote:

> >From the patch that I'm seeing, and if m_pszTabStops is allocated as
> m_pszTabStops = new char[1];
> then you can only leak 1 byte of memory. And to prevent the leaking you
> should do:

Well, I'm pretty sure that new will actually allocate more than one byte,
because tracking 1-byte allocations just sucks. Furthermore, you would
also leak the overhead of the data structures which track memory

But it's ok, since we free it in the destructor anyway.

> remember, when you allocate using new stuff[number]; you should
> deallocate using delete[] stuff. Or even better (for those that thinks
> that the macros actually make a difference) use DELETEPV(stuff);

The destructor uses delete thing;, not delete[] thing. Is that incorrect,
then? (I usually program in languages with garbage collection...)

> PS: btw, if m_pszTabStops is not a null terminated string (I don't see
> how it can be a null terminated string if it only has a byte), it should
> not use the prefix sz.

It's always a null terminated string, but gets reallocated when
changed; here, it's changed to a string of length 0 (so NULL is


This archive was generated by hypermail 2b25 : Fri Mar 30 2001 - 14:21:14 CST