[Freeciv-Dev] Re: (PR#13980) tileset memory leaks
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13980 >
Vasco Alexandre da Silva Costa wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13980 >
>
> On Thu, 15 Sep 2005, Jason Short wrote:
>
>
>><URL: http://bugs.freeciv.org/Ticket/Display.html?id=13980 >
>>
>>This patch fixes a number of tileset memory leaks.
>>
>>When I wrote the new tileset code I knew I wasn't rigorous about memory
>>handling. But I thought this was okay since it's easy to run valgrind
>>to find these errors. Well, this patch handles most of them.
>
> Why the casts to void * in the free() calls? The compiler shouldn't
> complain.
This is a problem repeated elsewhere. The hash code will only return
const pointers here and consts cannot be passed in to free.
My solution would be to add a hash_pop() function that pops off the
values; thus the key doesn't have to be constant anymore. It may also
be necessary to change the internal variable in the hash struct. I
believe there's already a ticket discussing this; Benoit had some ideas
about it.
-jason
|
|