Hi group, if i've got the function below...how can i free the memory used by
these variables?
Thanks
Herman
static Boolean FrmSelectSupplierFormHandleEvent(EventPtr event)
{
Boolean handled = false;
int i,x,y;
FormPtr frm;
FormPtr *frmNew;
//a pointer to a form
ControlPtr ctl;
_DynamicVouchers_Supplier_ID vRecordSupplierID;
char vLabel[MAX_VS+1];
char vVoucherSupplier[MAX_VS+1]; //for
retreiving dynamicDB info
char vVoucherSupplierID[MAX_VS+MAX_SUP_ID+1]; //for retreiving
dynamicSupplierIDDB info
char vNewRecord[MAX_VS+MAX_SUP_ID+1];
static EventType newEvent;
switch (event->eType) {
case ctlSelectEvent: // A control button was pressed and released.
if (event->data.ctlEnter.controlID == frmSelectSupplierCmdExitButton)
{
MemSet(&newEvent, sizeof(EventType), 0);
newEvent.eType = appStopEvent;
EvtAddEventToQueue(&newEvent);
handled = true;
}
else {
for (i=0;i<DmNumRecords(DynamicSupplierDB);i++) {
ReadRecord(DynamicSupplierIDDB,vVoucherSupplierID,i);
if (StrLen(vVoucherSupplierID) != MAX_VS+MAX_SUP_ID)
continue;
StrNCopy(vRecordSupplierID.dVoucherSupplier,vVoucherSupplierID,MAX_VS);
//get the supplier
vRecordSupplierID.dVoucherSupplier[MAX_VS] = 0;
StrNCopy(vRecordSupplierID.dVoucherID,vVoucherSupplierID+MAX_VS,MAX_SUP_ID);
//get the supplier
vRecordSupplierID.dVoucherID[MAX_SUP_ID] = 0;
if (event->data.ctlEnter.controlID ==
StrAToI(trim(vRecordSupplierID.dVoucherID))) {
StrCopy(gSupplierFormOrigin,trim(vRecordSupplierID.dVoucherSupplier));
FrmGotoForm(FrmPilotForm);
handled = true;
break;
}
}
}
case frmOpenEvent:
frm = FrmGetFormPtr (FrmSelectSupplierForm);
//get a pointer to the voucher form
frmNew = &frm;
//clear the DynamicTypeID database
while (DmNumRecords(DynamicSupplierIDDB) > 0)
DmRemoveRecord(DynamicSupplierIDDB,0);
//get a pointer to the form pointer
for (i=0;i<DmNumRecords(DynamicSupplierDB);i++) { //read all
the different suppliers from DynamicSupplierDB
ReadRecord(DynamicSupplierDB,vVoucherSupplier,i);
if (StrLen(vVoucherSupplier) != MAX_VS)
continue;
StrCopy(vLabel,vVoucherSupplier);
vLabel[MAX_VS] = 0;
//Add the supplier name and id to DynamicSupplierIDDB
StrPrintF(vNewRecord,"%s%*d",vLabel,MAX_SUP_ID,5000+i);
AddRecord(DynamicSupplierIDDB,vNewRecord);
CharPtr vTmp = (CharPtr)trim(vLabel); //pointer to
label
//button position
x = 42;
switch (i) {
case 0:
y = 30;
break;
case 1:
y = 60;
break;
case 2:
y = 90;
break;
case 3:
y = 120;
break;
}
ctl = CtlNewControl (frmNew, 5000+i, buttonCtl, vTmp, x, y, 75, 25,
FntGlueGetDefaultFontID (defaultBoldFont), 8000+i, false);
}
FrmDrawForm (FrmGetActiveForm());
handled = true;
break;
}
return(handled);
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/