summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2017-05-09 08:33:37 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2017-05-09 08:33:37 +0200
commit7d1dde01baad1e387a93833498f45167ff504acd (patch)
treebefab853668b38a46b0c7a4cce3dca4e52d08026 /tools.c
parent79b57feab6babc566fca72a7ae8a889d7758651a (diff)
downloadvdr-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.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools.c b/tools.c
index 754673db..a8e6af1e 100644
--- a/tools.c
+++ b/tools.c
@@ -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;
}