diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2017-05-09 08:33:37 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2017-05-09 08:33:37 +0200 |
commit | 7d1dde01baad1e387a93833498f45167ff504acd (patch) | |
tree | befab853668b38a46b0c7a4cce3dca4e52d08026 /tools.c | |
parent | 79b57feab6babc566fca72a7ae8a889d7758651a (diff) | |
download | vdr-7d1dde01baad1e387a93833498f45167ff504acd.tar.gz vdr-7d1dde01baad1e387a93833498f45167ff504acd.tar.bz2 |
The constructor of cHash (via cHashBase) now has an additional parameter (OwnObjects); fixed a memory leak in cSectionSyncerHash
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 4.5 2016/12/23 14:03:40 kls Exp $ + * $Id: tools.c 4.6 2017/05/09 08:32:54 kls Exp $ */ #include "tools.h" @@ -2312,9 +2312,10 @@ void cDynamicBuffer::Append(const uchar *Data, int Length) // --- cHashBase ------------------------------------------------------------- -cHashBase::cHashBase(int Size) +cHashBase::cHashBase(int Size, bool OwnObjects) { size = Size; + ownObjects = OwnObjects; hashTable = (cList<cHashObject>**)calloc(size, sizeof(cList<cHashObject>*)); } @@ -2348,6 +2349,13 @@ void cHashBase::Del(cListObject *Object, unsigned int Id) void cHashBase::Clear(void) { for (int i = 0; i < size; i++) { + if (ownObjects) { + cList<cHashObject> *list = hashTable[i]; + if (list) { + for (cHashObject *hob = list->First(); hob; hob = list->Next(hob)) + delete hob->object; + } + } delete hashTable[i]; hashTable[i] = NULL; } |