mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
The constructor of cHash (via cHashBase) now has an additional parameter (OwnObjects); fixed a memory leak in cSectionSyncerHash
This commit is contained in:
parent
79b57feab6
commit
7d1dde01ba
8
HISTORY
8
HISTORY
@ -8991,7 +8991,7 @@ Video Disk Recorder Revision History
|
||||
current channel is listed.
|
||||
- Fixed a possible crash when pulling the CAM while decrypting a channel with MTD.
|
||||
|
||||
2017-05-03: Version 2.3.5
|
||||
2017-05-09: Version 2.3.5
|
||||
|
||||
- CAMs are now sent a generated EIT packet that contains a single 'present event' for
|
||||
the current SID, in order to avoid any parental rating dialogs.
|
||||
@ -9001,3 +9001,9 @@ Video Disk Recorder Revision History
|
||||
Dietmar Spingler).
|
||||
- Events in the EIT that end before the EPG linger time are now ignored in the incoming
|
||||
data stream, because they would just be deleted in the next schedules cleanup anyway.
|
||||
- The constructor of cHash (via cHashBase) now has an additional parameter (OwnObjects)
|
||||
which, if set to true, makes the hash take ownership of the hashed objects, so that
|
||||
they are deleted when the hash is cleared or destroyed.
|
||||
- Fixed a memory leak in cSectionSyncerHash. The cSectionSyncerEntry objects put into
|
||||
the hash were never explicitly deleted. Now the cSectionSyncerHash takes ownership of
|
||||
these objects.
|
||||
|
7
eit.h
7
eit.h
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: eit.h 4.1 2015/07/25 11:03:53 kls Exp $
|
||||
* $Id: eit.h 4.2 2017/05/08 21:10:29 kls Exp $
|
||||
*/
|
||||
|
||||
#ifndef __EIT_H
|
||||
@ -15,7 +15,10 @@
|
||||
|
||||
class cSectionSyncerEntry : public cListObject, public cSectionSyncer {};
|
||||
|
||||
class cSectionSyncerHash : public cHash<cSectionSyncerEntry> {};
|
||||
class cSectionSyncerHash : public cHash<cSectionSyncerEntry> {
|
||||
public:
|
||||
cSectionSyncerHash(void) : cHash(HASHSIZE, true) {};
|
||||
};
|
||||
|
||||
class cEitFilter : public cFilter {
|
||||
private:
|
||||
|
12
tools.c
12
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;
|
||||
}
|
||||
|
11
tools.h
11
tools.h
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.h 4.6 2017/03/16 16:04:43 kls Exp $
|
||||
* $Id: tools.h 4.7 2017/05/09 08:33:37 kls Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TOOLS_H
|
||||
@ -825,9 +825,14 @@ class cHashBase {
|
||||
private:
|
||||
cList<cHashObject> **hashTable;
|
||||
int size;
|
||||
bool ownObjects;
|
||||
unsigned int hashfn(unsigned int Id) const { return Id % size; }
|
||||
protected:
|
||||
cHashBase(int Size);
|
||||
cHashBase(int Size, bool OwnObjects);
|
||||
///< Creates a new hash of the given Size. If OwnObjects is true, the
|
||||
///< hash takes ownership of the objects given in the calls to Add(),
|
||||
///< and deletes them when Clear() is called or the hash is destroyed
|
||||
///< (unless the object has been removed from the hash by calling Del()).
|
||||
public:
|
||||
virtual ~cHashBase();
|
||||
void Add(cListObject *Object, unsigned int Id);
|
||||
@ -841,7 +846,7 @@ public:
|
||||
|
||||
template<class T> class cHash : public cHashBase {
|
||||
public:
|
||||
cHash(int Size = HASHSIZE) : cHashBase(Size) {}
|
||||
cHash(int Size = HASHSIZE, bool OwnObjects = false) : cHashBase(Size, OwnObjects) {}
|
||||
T *Get(unsigned int Id) const { return (T *)cHashBase::Get(Id); }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user