I have four fields with repeating buttons used to add/subtract one from the total. This is done in the function below. However, I am running into an error :" just wrote to memory location xxx, which is in Memory Manager data struct". Seems like I am overrunning my pointer. I thought I was keeping up with the size of the pointer based on the number of digits in the field. What am I doing wrong??
(Note: I am new to C and Palm. Not sure where my mistake is) static void IncrementFormField(UInt16 fieldID, UInt8 numAction) { FormPtr frmP = FrmGetActiveForm(); FieldType *fldP; MemHandle handle; char *str; UInt8 number; fldP = (FieldType *)FrmGetObjectPtr(frmP,FrmGetObjectIndex(frmP, fieldID)); handle = FldGetTextHandle(fldP); if (handle) { FldSetTextHandle(fldP, NULL); str = MemHandleLock(handle); number = StrAToI(str); // Increment or decrement if (numAction == Increment) number += 1; else if (number > 0) number -= 1; // Resize pointer to minimum needed if (number > 99) MemPtrResize(str, 3); else if (number > 9) MemPtrResize(str, 2); //else //MemPtrResize(str, 1); StrIToA(str,number); SetFieldTextFromPtr(fieldID, str); } // Code to create new handle if not found . . . -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/