[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Freeing memory for Key itself in KeyedCollection ?
From: |
Jae Chan Oh |
Subject: |
Freeing memory for Key itself in KeyedCollection ? |
Date: |
Sun, 8 Jun 1997 15:33:25 -0400 (EDT) |
Hi,
I could only find one example for KeyedCollection type -- in SWARM GA package.
Now in the code, we have something like:
while ( ( member = [index next]) ) {
char* saux = calloc( 20, sizeof( char ) );
// Must be allocated to be used as key
sprintf( saux, "%f", [member getPersonStrength]);
if (! [newPplList at: (id) saux insert: member ] ) {
[SourceMessage raiseEvent : "Something is wrong\n" ];
}
}
---
My question is that when I want to remove some/all members of the above
collection, I would do something like the following:
// now remove all members of the list
index = [newPplList begin: [self getZone]];
while ( ( me = [index next]) ) {
[me drop];
[index remove];
}
[index drop];
---
But it seems that the memory for Keys allocated using "calloc" are
not freed in the above method -- so there goes a memory leak.
What is a correct way to free to memory for KeyedCollection that also
frees the memory for Keys as well?
Thanks bunch.
-Jae
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Freeing memory for Key itself in KeyedCollection ?,
Jae Chan Oh <=