Hello, Eric
I think no difference between new and MemPtrNew. Look these files (New.cp,
NewMore.cp included to the CodeWarrior C++ Runtime code).

This code from New.cp:

...
#define MALLOCFUNC(x)   MemPtrNew(x)
#define MFREEFUNC(x)    MemChunkFree(x)
...

#ifndef OPERATOR_NEW
#define OPERATOR_NEW    operator new
#endif
#ifndef OPERATOR_DELETE
#define OPERATOR_DELETE operator delete
#endif
...
/************************************************************************/
/*  Purpose..:  Allocate memory                                         */
/*  Input....:  size of memory to allocate                              */
/*  Return...:  pointer to memory or 0L                                 */
/************************************************************************/
void *OPERATOR_NEW(size_t size) throw(bad_alloc)
{
    void *ptr;

#if defined(__MODENALIB__) && NEWMODE==NEWMODE_MALLOC
    if (size==0) { size = sizeof(int); }     // hh 971208 Changed sizeof(1)
to sizeof(int)
#endif

    for(;;)
    {
        if((ptr=MALLOCFUNC(size))!=NULL) break;
        if(!__new_handler)
        {
            __throw_bad_alloc();
             break;
        }
        __new_handler();
    }
    return ptr;
}
...

/************************************************************************/
/*  Purpose..:  Dispose memory                                          */
/*  Input....:  pointer to memory or 0L (no action if 0L)               */
/*  Return...:  ---                                                     */
/************************************************************************/
void OPERATOR_DELETE(void *ptr) throw()
{
    if(ptr) MFREEFUNC((PTRTYPE)ptr);
}
...
...

Good Luck.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Lee, Eric
Sent: Wednesday, December 27, 2000 5:39 PM
To: Palm Developer Forum
Subject: MemPtrNew Vs. new


Hello all

I have a question about MemPtrNew and new.   I know that MemPtrNew is used

to get non-movable chucks of memory and new is used for declaring class,
arrarys.  Besides the fact that new also calls the constructor of the
desired class, anyone knows the exact difference between new and MemPtrNew?
Is new allocate the memory like MemPtrNew does?  For example, char* pChar =
new char[100];  pChar has a non-movable chuck of memory or movable?  what is
the exact difference between new and MemPtrNew?

sincerely


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


-- 
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