You should use a handle rather than a pointer if you want to be able to
resize it larger. You're allowed to resize pointers, but it's only
guaranteed to work if you're making it smaller. You get memErrChunkLocked if
there isn't space available in the heap just after the chunk.

Here's my version of your code:

MemHandle    fooH;
fooH=MemHandleNew(50);
result=MyCall(fooH);
DoSomething(fooH);
MemHandleFree(fooH);
/-----------------------------/
int    MyCall(MemHandle foodH) {
    switch(MemHandleResize(foodH, 100)) {
        case memErrChunkLocked
            FrmCustomAlert(TestAlert, "fails here!!", " ", " ");
            break;
    }
}

To actually read and write data, you'll need code like this:

CharPtr foo = MemHandleLock(fooH);
...use foo here...
MemHandleUnlock(fooH);
--
Danny Epstein
OS Engineer, Palm Inc.



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to