fixed misc *_free functions to accept NULL

Following types of collections support now
NULL in the free call:

* ArrayList
* BitStream
* ContdownEvent
* Dictionary
* KeyValuePair
* MessageQueue
This commit is contained in:
Martin Haimberger 2015-07-30 07:02:36 -07:00
parent ee41790dea
commit 008d9f3b79
6 changed files with 18 additions and 0 deletions

View File

@ -470,6 +470,9 @@ out_free:
void ArrayList_Free(wArrayList *arrayList)
{
if (!arrayList)
return;
ArrayList_Clear(arrayList);
DeleteCriticalSection(&arrayList->lock);
free(arrayList->array);

View File

@ -348,5 +348,8 @@ wBitStream* BitStream_New()
void BitStream_Free(wBitStream* bs)
{
if (!bs)
return;
free(bs);
}

View File

@ -182,6 +182,9 @@ fail_critical_section:
void CountdownEvent_Free(wCountdownEvent* countdown)
{
if (!countdown)
return;
DeleteCriticalSection(&countdown->lock);
CloseHandle(countdown->event);

View File

@ -128,6 +128,9 @@ wDictionary* Dictionary_New(BOOL synchronized)
void Dictionary_Free(wDictionary* dictionary)
{
if (!dictionary)
return;
free(dictionary);
}

View File

@ -46,5 +46,8 @@ wKeyValuePair* KeyValuePair_New(void* key, void* value)
void KeyValuePair_Free(wKeyValuePair* keyValuePair)
{
if (!keyValuePair)
return;
free(keyValuePair);
}

View File

@ -223,6 +223,9 @@ error_array:
void MessageQueue_Free(wMessageQueue* queue)
{
if (!queue)
return;
CloseHandle(queue->event);
DeleteCriticalSection(&queue->lock);