Calloc nodes in GSIMap instead of mallocing them. This ensures that their initial value is always zero and so can be released safely.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35924 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2012-12-27 12:42:56 +00:00
parent 59abbdce64
commit 2d7d985188

View file

@ -561,15 +561,15 @@ static INLINE void
GSIMapMoreNodes(GSIMapTable map, unsigned required)
{
GSIMapNode *newArray;
uintptr_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
#if GS_WITH_GC
uintptr_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
/* We don't want our nodes collected before we have finished with them,
* so we must keep the array of pointers to memory chunks in scanned memory.
*/
newArray = (GSIMapNode*)NSAllocateCollectable(arraySize, NSScannedOption);
#else
newArray = (GSIMapNode*)NSZoneMalloc(map->zone, arraySize);
newArray = (GSIMapNode*)NSZoneCalloc(map->zone, (map->chunkCount+1), sizeof(GSIMapNode));
#endif
if (newArray)
{
@ -605,7 +605,7 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
newNodes = GSI_MAP_NODES(map, chunkCount);
#else
newNodes
= (GSIMapNode)NSZoneMalloc(map->zone, chunkCount*sizeof(GSIMapNode_t));
= (GSIMapNode)NSZoneCalloc(map->zone, chunkCount, sizeof(GSIMapNode_t));
#endif
if (newNodes)
{