mirror of https://github.com/FreeRDP/FreeRDP
ListDictionary_Remove: return value if removed
Update tests accordingly.
This commit is contained in:
parent
f24cd91bae
commit
86e53aed9a
|
@ -197,7 +197,7 @@ typedef struct _wListDictionary wListDictionary;
|
|||
WINPR_API int ListDictionary_Count(wListDictionary* listDictionary);
|
||||
|
||||
WINPR_API void ListDictionary_Add(wListDictionary* listDictionary, void* key, void* value);
|
||||
WINPR_API void ListDictionary_Remove(wListDictionary* listDictionary, void* key);
|
||||
WINPR_API void* ListDictionary_Remove(wListDictionary* listDictionary, void* key);
|
||||
WINPR_API void ListDictionary_Clear(wListDictionary* listDictionary);
|
||||
|
||||
WINPR_API BOOL ListDictionary_Contains(wListDictionary* listDictionary, void* key);
|
||||
|
|
|
@ -198,10 +198,11 @@ BOOL ListDictionary_Contains(wListDictionary* listDictionary, void* key)
|
|||
* Removes the entry with the specified key from the ListDictionary.
|
||||
*/
|
||||
|
||||
void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
|
||||
void *ListDictionary_Remove(wListDictionary* listDictionary, void* key)
|
||||
{
|
||||
wListDictionaryItem* item;
|
||||
wListDictionaryItem* prevItem;
|
||||
void *value = NULL;
|
||||
|
||||
if (listDictionary->synchronized)
|
||||
EnterCriticalSection(&listDictionary->lock);
|
||||
|
@ -213,6 +214,7 @@ void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
|
|||
if (listDictionary->head->key == key)
|
||||
{
|
||||
listDictionary->head = listDictionary->head->next;
|
||||
value = item->value;
|
||||
free(item);
|
||||
}
|
||||
else
|
||||
|
@ -227,6 +229,7 @@ void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
|
|||
if (item->key == key)
|
||||
{
|
||||
prevItem->next = item->next;
|
||||
value = item->value;
|
||||
free(item);
|
||||
break;
|
||||
}
|
||||
|
@ -239,6 +242,7 @@ void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
|
|||
|
||||
if (listDictionary->synchronized)
|
||||
LeaveCriticalSection(&listDictionary->lock);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,6 +113,18 @@ int TestListDictionary(int argc, char* argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!ListDictionary_Remove(list, key2))
|
||||
{
|
||||
printf("ListDictionary_Remove: Expected : %d, Actual: %d\n", TRUE, FALSE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ListDictionary_Remove(list, key2))
|
||||
{
|
||||
printf("ListDictionary_Remove: Expected : %d, Actual: %d\n", FALSE, TRUE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ListDictionary_Clear(list);
|
||||
|
||||
count = ListDictionary_Count(list);
|
||||
|
|
Loading…
Reference in New Issue