iBuffPtr is passed by value: iLen = BBB(iBuffPtr);
Therefore, even if BBB changes the value of iBuffPtr, the caller (namely AAA) will not see the change. One fix would be to pass a pointer to iBuffPtr. The above call would look like: iLen = BBB(&iBuffPtr); and BBB would look like: //---------------------------------------------------------------------- //---------------------------------------------------------------------- UInt16 BBB(UInt8** iDataPtr) { UInt16 iLen; Char sStr[] = "Test Data"; Err err; iLen = StrLen(sStr); *iDataPtr = (UInt8*)MemPtrNew(iLen+1); err = MemMove (*iDataPtr, sStr,iLen+1); return iLen+1; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- Hope this helps. Dennis Leas ----------- [EMAIL PROTECTED] -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ken Sent: Tuesday, July 01, 2003 6:13 PM To: Palm Developer Forum Subject: MemPtr Help Hi, Below is sample code of what I would like to do (which does not work). Function BBB allocates memory and loads the buffer and then AAA uses the data and then deletes the buffer. The pointer to the memory buffer does not get passed back to AAA correctly. So I have missed something in the way the MemPtr function work. I would like to know how to make it work with the MemPtr functions. Thanks, Ken //---------------------------------------------------------------------- //---------------------------------------------------------------------- void AAA(void) { UInt8* iBuffPtr=NULL; UInt16 iLen; iLen = BBB(iBuffPtr); //do something with iBuffPtr MemPtrFree(iBuffPtr); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- UInt16 BBB(UInt8* iDataPtr) { UInt16 iLen; Char sStr[] = "Test Data"; Err err; iLen = StrLen(sStr); iDataPtr = (UInt8*)MemPtrNew(iLen+1); err = MemMove (iDataPtr, sStr,iLen+1); return iLen+1; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/