Fixes for multiple insertion of same value.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13046 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-03-08 07:11:10 +00:00
parent 8c0d705d47
commit f2c6708cf5
3 changed files with 30 additions and 2 deletions

View file

@ -367,6 +367,7 @@ void
NSMapInsert(NSMapTable *table, const void *key, const void *value)
{
GSIMapTable t = (GSIMapTable)table;
GSIMapNode n;
if (table == 0)
{
@ -378,7 +379,19 @@ NSMapInsert(NSMapTable *table, const void *key, const void *value)
[NSException raise: NSInvalidArgumentException
format: @"Attempt to place notAKeyMarker in map table"];
}
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
n = GSIMapNodeForKey(t, (GSIMapKey)key);
if (n == 0)
{
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
}
else
{
GSIMapVal tmp = n->value;
n->value = (GSIMapVal)value;
GSI_MAP_RETAIN_VAL(t, n->value);
GSI_MAP_RELEASE_VAL(t, tmp);
}
}
/**