Bob Ebert wrote:

> At 2:55 PM -0800 3/9/99, Tung Bui wrote:
> >I mean I would prefer two operations (new and delete) over
> >four operations (MemHandleNew, MemHandleLock, MemHandleUnlock and
> >MemPtrFree) since it is simpler to allocate and deallocate memory the C++
> >way.
>
> You might consider MemPtrNew and MemPtrFree.  If you're going to allocate
> then immediately lock a handle, and only unlock it right before you free
> it, then you should use a fixed chunk (pointer) instead.  ...now you're
> back to just 2 operations.
>
> I don't know how the C++ compiler implements new/delete, so I can't say
> whether that's better or worse than using MemPtrNew/MemPtrFree.

MW C++ uses MemPtrNew and MemPtrFree for new and delete respectively. If you
use new and delete then you can use the auto_ptr class for non-array
allocations. auto_ptr is supplied with Teenee, our popular C++ application
framework for PalmOS (http://www.classactionpl.com/). Teenee 1.1.0
(forthcoming) has an ArrayPtrSentry class that handles new[] and delete[]. I
can include the source for this in advance upon request.


--
Christopher Hunt
Class Action Pty. Ltd.

Are you a time zone traveler that owns a Palm(tm) connected organizer?
Check out http://www.classactionpl.com/TimeTraveler/index.htm

Reply via email to