ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/arch.C
(Generate patch)

Comparing deliantra/server/common/arch.C (file contents):
Revision 1.76 by root, Wed Apr 30 06:40:28 2008 UTC vs.
Revision 1.79 by root, Sun May 4 11:12:40 2008 UTC

133 * - name: The name we're searching for (ex: "writing pen"); 133 * - name: The name we're searching for (ex: "writing pen");
134 * Return value: 134 * Return value:
135 * - a corresponding object if found; a singularity object if not found. 135 * - a corresponding object if found; a singularity object if not found.
136 * Note by MSW - it appears that it takes the full name and keeps 136 * Note by MSW - it appears that it takes the full name and keeps
137 * shortening it until it finds a match. I re-wrote this so that it 137 * shortening it until it finds a match. I re-wrote this so that it
138 * doesn't malloc it each time - not that this function is used much, 138 * doesn't allocate it each time - not that this function is used much,
139 * but it otherwise had a big memory leak. 139 * but it otherwise had a big memory leak.
140 */ 140 */
141object * 141object *
142get_archetype_by_object_name (const char *name) 142get_archetype_by_object_name (const char *name)
143{ 143{
511 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object 511 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object
512 ++idx; 512 ++idx;
513 else 513 else
514 { 514 {
515 LOG (llevDebug, "garbage collect arch %s", at->debug_desc ()); 515 LOG (llevDebug, "garbage collect arch %s", at->debug_desc ());
516 assert (at->arch == at); // verify that refcnt == 1 is truely valid 516 assert (at->arch == at); // verify that refcnt == 1 is truly valid
517 allarch.erase (idx); 517 allarch.erase (idx);
518
519 // break chain
520 for (object *op = at->head_ (); op; )
521 {
522 object *next = op->more;
523 op->head = 0;
524 op->more = 0;
525 op = next;
526 }
527
528 at->destroy ();
518 at->arch = 0; 529 at->arch = 0;
519 at->more = 0;
520 at->destroy ();
521 } 530 }
522 } 531 }
523 while (--cnt); 532 while (--cnt);
524} 533}
525 534

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines