"Lee, Eric" <[EMAIL PROTECTED]> wrote in message
news:32534@palm-dev-forum...
>
> malloc is fine because I can define the macro like
> #define malloc MemPtrNew
> However, I can't use MemPtrResize for realloc because it returns Err
> datatype instead of MemPtr or Void * .  Anyone knows how should I do
realloc
> better way?  Do I have to come up with some sort of a function that will
> overwrite the MemPtrResize?
>
> Thanks in advance.
>
> sincerely
>
> p.s.  I am currently using Palm OS 3.5


Since a MemPtr as returned by the MemPtrNew routine is really a locked
handle, you could insert this in your header -- make inline or not per your
preferences:

static __inline void *malloc(UInt16 size)
{
    return MemPtrNew(size);
}

static __inline void free(void *ptr)
{
    MemPtrFree(ptr);
}

static void *realloc(void *ptr, UInt16 size)
{
    MemHandle mh = MemPtrRecoverHandle(ptr);
    MemHandleUnlock(mh);
    MemHandleResize(mh, size);
    return MemHandleLock(mh);
}




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to