Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10667) memory leak in effects ruleset cache
Home

[Freeciv-Dev] (PR#10667) memory leak in effects ruleset cache

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10667) memory leak in effects ruleset cache
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Oct 2004 10:45:04 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10667 >

==4732== 3400 bytes in 196 blocks are definitely lost in loss record 13 
of 16
==4732==    at 0x1B906EDD: malloc (vg_replace_malloc.c:131)
==4732==    by 0x804B512: fc_real_malloc (mem.c:79)
==4732==    by 0x80BEA24: ruleset_cache_add (effects.c:562)
==4732==    by 0x80891F5: load_ruleset_buildings (ruleset.c:1408)
==4732==    by 0x808F137: load_rulesets (ruleset.c:3228)
==4732==    by 0x8051E5F: srv_loop (srv_main.c:1695)
==4732==    by 0x8051D4B: srv_main (srv_main.c:1647)
==4732==    by 0x804A94E: main (civserver.c:170)

This patch fixes it.

jason

Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 effects.c
--- common/effects.c    10 Oct 2004 21:18:03 -0000      1.13.2.1
+++ common/effects.c    21 Oct 2004 17:38:45 -0000
@@ -478,6 +478,10 @@
     building_vector_free(get_buildings_with_effect(i));
 
     for (j = 0; j < ARRAY_SIZE(ruleset_cache.effects[i].buckets); j++) {
+      effect_list_iterate(*get_building_effects(j, i), peffect) {
+       /* Allocated in ruleset_cache_add. */
+       free(peffect);
+      } effect_list_iterate_end;
       effect_list_unlink_all(get_building_effects(j, i));
     }
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#10667) memory leak in effects ruleset cache, Jason Short <=