Ok got it.  It now reads

void mobstat_update (void)
{
     FILE *fp;
     int vnum;
     MOB_INDEX_DATA *pMobIndex;
     CHAR_DATA *mob;
     int nMatch;
     char buf[MSL];

    fclose(fpReserve);

    fp = fopen("../data/mobstat.txt","w");

    nMatch = 0;
    for (vnum = 0; nMatch < top_mob_index; vnum++)
    if ((pMobIndex = get_mob_index(vnum)) != NULL)
    {
      nMatch++;
      if ( ( pMobIndex = get_mob_index( vnum ) ) != NULL )
      {
       if pMobIndex->kills >= 3 || pMobIndex->killed >= 3)
       {
        sprintf(buf,"%5d %5d %5d\n", pMobIndex->vnum, pMobIndex->kills,
pMobIndex->killed);
        fprintf( fp, buf );
       }
      }
    }
     fprintf(fp,"-1");
     fclose(fp);
     fpReserve = fopen( NULL_FILE, "r" );
     return;
}

Still doesn't tell me why the stats are not loading onto the index....but a
big help in the memory department.

Thanks for the help!
-T 

>>>>-----Original Message-----
>>>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
>>>>Behalf Of [EMAIL PROTECTED]
>>>>Sent: Wednesday, September 28, 2005 1:18 PM
>>>>To: KJM
>>>>Cc: [email protected]
>>>>Subject: Re: Question about a function to track stats.
>>>>
>>>>
>>>>First off, this looks like a HUGE memory leak to me at "mob 
>>>>= create_mobile( pMobIndex )", you are creating a new copy 
>>>>of every mob every 5 minutes and then not freeing it?  If 
>>>>you can (presumably) just set the index data in the other 
>>>>function (fight.c does it to the value 'killed' when you 
>>>>kill a mob), why can't you just read it back from the index 
>>>>instead of making a new mob and then losing it somewhere?
>>>>
>>>>Brian.
>>>>
>>>>>      if ( ( pMobIndex = get_mob_index( vnum ) ) != NULL )
>>>>>      {
>>>>>       mob = create_mobile( pMobIndex );
>>>>>       if (mob->pIndexData->kills >= 3 || 
>>>>mob->pIndexData->killed >= 3)
>>>>>       {
>>>>>        sprintf(buf,"%5d %5d %5d\n", mob->pIndexData->vnum,
>>>>> mob->pIndexData->kills, mob->pIndexData->killed);
>>>>
>>>>
>>>>--
>>>>ROM mailing list
>>>>[email protected]
>>>>Unsubscribe here ->>> 
>>>>http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to