static void DetailsHeaderInit(MemHandle * LH)
{
I have this routine which I use to initialize some labels on a form. I am
getting an this error in Pose, running gremlin 0.

3352.192 (7901):        === ERROR: Gremlin #0 Event 7900
3352.193 (7901):        === ERROR: 
********************************************************************************
3352.193 (7901):        === ERROR: "Job Tracker" 0.5.0 has just read directly from 
memory manager data structures.

This problem indicates an error in the application.  Users should upgrade this product 
immediately to safeguard their data.
3352.193 (7901):        === ERROR: 
********************************************************************************
3354.039 (7901):        === ERROR: Gremlin #0 terminated in error at event #7900

The error occurs as marked below in this routine...

        AccessArrayPtr  lap;
        FormPtr frm;
        Char * tmpstr = NULL;
        MemHandle       jhandle;
        
        
        lap = MemHandleLock(*LH);
        JobDataGetRecord(JobListDB,lap->jobrecnum,&lap->jobdata,&jhandle);
        
        frm = FrmGetFormPtr(jobdetailsform);
        
        // copy job number to top label
        FrmCopyLabel(frm,detailsjobnumlabel,lap->jobdata.fields[inumber]);    
                if (StrLen(lap->jobdata.fields[icustomer]) > 24)     {          
                tmpstr = MemPtrNew(26);                  
        tmpstr = StrNCopy(tmpstr,lap->jobdata.fields[icustomer],24);            
>>>>>   FrmCopyLabel(frm,detailcustlabel,tmpstr);               
        MemPtrFree(tmpstr);

It blows up on FrmCopyLabel.  The detailcustlabel is defined in the rcp file as
xx... 26 times. I am attempting to truncate the string to fit into the label.
24 should work, and in fact does work if I test the routine with a long string.

In the debugger, If I look at lap->jobdata.fields[icustomer], it is as
expected. After I do the StrNCopy into tmpstr, tmpstr is a copy for the first
21 letters, then corrupted characters. 22 nd char is different, 23 is /002, 24 
is /000. I suspect FrmCopyLabel is blowing up on the /002, or ??. Each time I
run it, the corrupted characters are the same. I have tried to get it to do the
same outside of the gremlins, with no success.

I don't know what is happening here. tmpstr is initialized as NULL, MemPtrNew
succeeds, ie. tmpstr is not NULL. lap->jobdata.fields[icustomer] is a struct
which contains the jobdata struct into which is unpacked the database packed
record, with an array of charptrs. The data is locked, then unlocked at the end
of the routine.

Why is StrNCopy not faithfully copying the string?

Linux, prctools 2.0, 3.5 sdk, pose 3.07 for linux, 
palmos35-dr4-en-nonezdbg.rom, palmIII device, 1024K. 

Thanks

Derek (I hope this gets on the somewhat intermittant list)

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to