Difference for common/object.c from version 1.26 to 1.27


version 1.26 version 1.27
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_object_c =   * static char *rcsid_object_c =
  *   "$Id: object.c,v 1.26 2001/05/09 06:58:12 mwedel Exp $";   *   "$Id: object.c,v 1.27 2001/05/12 23:55:24 mwedel Exp $";
  */   */
   
 /*  /*
Line 317
 
Line 317
 }  }
   
 void free_all_object_data() {  void free_all_object_data() {
     object *op, *next;  
   
 #if 0  #if 0
   
     /* Don't clean these up, so that properly allocated but 'lost' objects      /* Don't clean these up, so that properly allocated but 'lost' objects
      * still show up in memory debugging output.       * still show up in memory debugging output.  This is things like
        * a function doing a get_ob, but not freeing it.
      */       */
     for (op=objects; op!=NULL; op=next) {      for (op=objects; op!=NULL; op=next) {
  next=op->next;   next=op->next;
Line 333
 
Line 334
 #endif  #endif
   
 #ifdef MEMORY_DEBUG  #ifdef MEMORY_DEBUG
     /* In theory, we should do this.  In practice, it is fairly difficult      object *op, *next;
      * because objects are created in groups of 100, and there is no record  
      * of those starting pointers.  
      */  
     for (op=free_objects; op!=NULL; ) {      for (op=free_objects; op!=NULL; ) {
  next=op->next;   next=op->next;
  free(op);   free(op);
Line 659
 
Line 658
   
 object *get_object() {  object *get_object() {
   object *op;    object *op;
   
   if(free_objects==NULL) {    if(free_objects==NULL) {
     expand_objects();      expand_objects();
   }    }
   op=free_objects;    op=free_objects;
   #ifdef MEMORY_DEBUG
     /* The idea is hopefully by doing a realloc, the memory
      * debugging program will now use the current stack trace to
      * report leaks.
      */
     op = realloc(op, sizeof(object));
     SET_FLAG(op, FLAG_REMOVED);
     SET_FLAG(op, FLAG_FREED);
   #endif
   
   if(!QUERY_FLAG(op,FLAG_FREED)) {    if(!QUERY_FLAG(op,FLAG_FREED)) {
     LOG(llevError,"Fatal: Getting busy object.\n");      LOG(llevError,"Fatal: Getting busy object.\n");
   }    }
Line 1002
 
Line 1012
       ob->next->prev=ob->prev;        ob->next->prev=ob->prev;
   }    }
      
   /* Now link it with the free_objects list: */  
   ob->prev=NULL;  
   ob->next=free_objects;  
   if(free_objects!=NULL)  
     free_objects->prev=ob;  
   free_objects=ob;  
   if(ob->name!=NULL) {    if(ob->name!=NULL) {
     free_string(ob->name);      free_string(ob->name);
     ob->name=NULL;      ob->name=NULL;
Line 1028
 
Line 1032
     free_string(ob->msg);      free_string(ob->msg);
     ob->msg=NULL;      ob->msg=NULL;
   }    }
   
   #if 0 /* MEMORY_DEBUG*/
       /* This is a nice idea.  Unfortunately, a lot of the code in crossfire
        * presumes the freed_object will stick around for at least a little
        * bit
        */
       /* this is necessary so that memory debugging programs will
        * be able to accurately report source of malloc.  If we recycle
        * objects, then some other area may be doing the get_object
        * and not freeing it, but the original one that malloc'd the
        * object will get the blame.
        */
       free(ob);
   #else
     /* Now link it with the free_objects list: */
     ob->prev=NULL;
     ob->next=free_objects;
     if(free_objects!=NULL)
       free_objects->prev=ob;
     free_objects=ob;
   nroffreeobjects++;    nroffreeobjects++;
   #endif
   
 }  }
   
 /*  /*


Legend:
line(s) removed in v.1.26 
line(s) changed
 line(s) added in v.1.27

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:15