mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 12:16:40 +00:00
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:
parent
8c0d705d47
commit
f2c6708cf5
3 changed files with 30 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue