AyloNs Hazzud wrote:
> Err PrvMedindoPegaItem(void *tableP, Int16 row, Int16 column, Boolean
> editable,
> MemHandle *dataH, Int16 *dataOffset, Int16
> *dataSize,
> FieldPtr fld){
> FieldAttrType attr;
> Char * dataP;
> AnPiRecordPtr recordP;
> MemHandle recordH, fldH;
>
> /*Aproveita que a funÃÃo lida field a field e os configura*/
> FldGetAttributes(fld, &attr);
> attr.justification = rightAlign;
> attr.numeric = true;
> attr.singleLine = true;
> FldSetAttributes(fld, &attr);
>
>
> FldSetMaxChars(fld, 6);
> *dataSize = FldGetMaxChars(fld) + 1;
> *dataOffset = 0;
>
> /*Retorna 1 se houver erro na alocaÃÃo da memÃria*/
> if (!(fldH = MemHandleNew(*dataSize)))
> return 1;
>
> recordH = DmQueryRecord(AnPiDB, CurrentRecord);
> ErrFatalDisplayIf(DmGetLastRecord(), "Record nÃo encontrado");
>
> recordP = MemHandleLock(recordH);
>
> dataP = (Char *) MemHandleLock(fldH);
>
> /*record->estado diz a medida atual*/
> FlpFToText(recordP->P[recordP->estado][row][column], dataP,
> *dataSize - 1);
>
> MemHandleUnlock(fldH);
> MemHandleUnlock(recordH);
>
> *dataH = fldH;
>
> return 0;
>
> }
Since you're getting read errors from 0x000000 and 0x000002 and
since you have two pointers of type (Int16 *), it seems suspicious
that maybe one of them is NULL. Have you tried validating
all the arguments at the beginning of the function, like this:
if (! tableP || ! dataH || ! dataOffset || ! dataSize || ! fld)
{
FrmCustomAlert (MyAlert, "NULL pointer passed", "", "");
return 1;
}
Also, it looks like you are storing a pointer (the "P" member
of the AnPiRecord) in a database. That can be a bad idea.
Are you sure that after you read recordP that the pointer
recordP->P actually points anywhere?
Beyond that, my best advice is to step through this function
in the debugger to establish exactly *which* line of code is
accessing memory at 0x000000. That should at least tell you
which pointer is invalid. (If you don't want to use the
debugger, put a bunch of FrmCustomAlert()s in and then you
have to click "OK" over and over again, and one time after
you click "OK", the system will print its error message
about invalid access to 0x000000. Then you know it's after
the FrmCustomAlert() you just clicked "OK" for.)
- Logan
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/