SysFatalAlert,MemoryMgr.c, Line:4384, Free Handle - Urgent

Hi,

SysFatalAlert,MemoryMgr.c, Line:4384, Free Handle
when I called the below function, it gives the above error message.
Please give solution for this.
Thanks in advance
Boolean tablePopulationFunction()
{
      LocalID                        dbID = NULL;
      DmOpenRef                   dbRef= NULL;
      MemHandle                  mhRecHandle = NULL;
                  
      JOBINFO*                  stJobInfoP = 0;
      CARTRIDGES* stCartInfoP = 0;
            
      //get the Pointer of the Table
      TablePtr tblP = ( TablePtr ) GetObjectPtr( JobAssignmentLocationTable );
      //for the Row of the Table.
      int                         iRow = 0;
      //for the column of the table.
      int                         iCol = 0;
      //Get the number of rows in the Table.
      int                         iRows = TblGetNumberOfRows( tblP );
      //Get the Number of Items in the Table.
      int                         iNumItems = giEndIndex - giStartIndex;
      int                         iCounter = 0;
      //for the Total Number of Records in the Database.
      int                         iNumRecordsInDatabase = 0;
            
      ErrTry
      {
            tblP = ( TablePtr ) GetObjectPtr( JobAssignmentLocationTable );
             TblHasScrollBar( tblP, true );
            TblEraseTable( tblP );
            TblMarkTableInvalid ( tblP );

            int      iNumRecordsinDatabase = 0;                  

                  dbID = DmFindDatabase( 0,JOBINFODB );      
                  if( dbID == 0 )
                  {
                        FrmCustomAlert( ErrorAlert,NODATABASE," " ," "  );      
                        closeApplication();
                        return false;
                  }
                  dbRef       = DmOpenDatabase( 0, dbID, dmModeReadOnly );
                  if(dbRef == 0)
                  {
                        FrmCustomAlert( ErrorAlert,DATABASEOPENPROB," " ," "  );      
                        closeApplication();
                        return false;
                  }

                  iNumRecordsInDatabase = DmNumRecords( dbRef );
                  iNumItems = iNumRecordsInDatabase;

                  for( int iRowCtr = 0;  iRowCtr < iRows; iRowCtr++ )
                  {
                        TblSetRowUsable( tblP, iRowCtr, false );
                  }
                  iNumRecordsInDatabase = DmNumRecords(dbRef);

                  int iCtr = 0;
                  
      for( int idx = giStartIndex; idx  < giEndIndex && idx < iNumRecordsInDatabase; idx++ )
                  {

                        mhRecHandle = DmQueryRecord( dbRef, idx );
                        if(mhRecHandle == NULL)
                        {
                              FrmCustomAlert(ErrorAlert,RECORDGETTING," " ," ");
                              DmCloseDatabase(dbRef);
                              return false;
                        }
                                                
                        Err err2 = DmGetLastErr();                                          
                        stJobInfoP = ( JOBINFO * ) MemHandleLock( mhRecHandle );
                        Err err3 = DmGetLastErr();
                        
                                                
                        //set the data for the iRow that is the location.
                        TblSetRowUsable( tblP, iRow, true );
                        TblSetColumnUsable ( tblP, iCol, true );
                        TblSetItemStyle( tblP, iRow, iCol, labelTableItem );
      TblSetItemPtr( tblP, iRow , iCol , ( char* )stJobInfoP->cFunctionLocationId );
                        
                        //now increment the iCol int to point to the next row
                        //This is for the Job Type Column.
                        TblSetRowUsable( tblP, iRow, true );
                        TblSetColumnUsable ( tblP, iCol + 1, true );
                        TblSetItemStyle( tblP, iRow, iCol + 1, labelTableItem );
                        if(giJobType == 1 || giJobType == 4)
                              TblSetItemPtr( tblP, iRow , iCol + 1 , ( char* )stJobInfoP->cAtmType );
                        else
                              TblSetItemPtr( tblP, iRow , iCol + 1 , ( char* )stJobInfoP->cJobType );
                        
                        //now increment the iCol int to point to the next row
                        
                        //This is for the Status Column.
                        TblSetRowUsable( tblP, iRow, true );
                        TblSetColumnUsable ( tblP, iCol + 2, true );
                        TblSetItemStyle( tblP, iRow, iCol + 2 , labelTableItem );

                        //Here we check if teh Job has been completed or not.
                        if( stJobInfoP->bSavedStatus)      
                        {
                              TblSetItemPtr( tblP, iRow , iCol + 2 , (char*)"C" );
                        }
                        else
                        {
                              TblSetItemPtr( tblP, iRow , iCol + 2  , (char*)"P" );
                        }
                        if (mhRecHandle != NULL )
                        {
                              MemHandleUnlock( mhRecHandle );
                        }                  
                        //increment counters for the array  and for the iRow
                        
                        iCtr++;
                        iRow++;
                  }                                    
                  DmCloseDatabase( dbRef );
                        
                  
            tblP = ( TablePtr ) GetObjectPtr( JobAssignmentLocationTable );
            TblDrawTable( tblP );
            
            stJobInfoP = NULL;            
      }
      ErrCatch(err ){
            ErrDisplay("Error");
      }ErrEndCatch
      
      return true;
}
yasodaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mikal613Commented:
which line gives you the error?

One solution is

you are using two handles, but, only one variable

2) your writing to a Object thats closed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yasodaAuthor Commented:
Hi,
it is giving error in the stJobInfoP = ( JOBINFO * ) MemHandleLock( mhRecHandle );

Err err2 = DmGetLastErr();                                  
stJobInfoP = ( JOBINFO * ) MemHandleLock( mhRecHandle );
Err err3 = DmGetLastErr();

waiting for ur reply
Thanks in advance
adesh
0
yasodaAuthor Commented:
Hi,
it is giving error in the stJobInfoP = ( JOBINFO * ) MemHandleLock( mhRecHandle );

Err err2 = DmGetLastErr();                                  
stJobInfoP = ( JOBINFO * ) MemHandleLock( mhRecHandle );
Err err3 = DmGetLastErr();

Thanks in advance
adesh
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.