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.
|
current channel is listed.
|
||||||
- Fixed a possible crash when pulling the CAM while decrypting a channel with MTD.
|
- 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
|
- 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.
|
the current SID, in order to avoid any parental rating dialogs.
|
||||||
@ -9001,3 +9001,9 @@ Video Disk Recorder Revision History
|
|||||||
Dietmar Spingler).
|
Dietmar Spingler).
|
||||||
- Events in the EIT that end before the EPG linger time are now ignored in the incoming
|
- 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.
|
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
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __EIT_H
|
||||||
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
class cSectionSyncerEntry : public cListObject, public cSectionSyncer {};
|
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 {
|
class cEitFilter : public cFilter {
|
||||||
private:
|
private:
|
||||||
|
12
tools.c
12
tools.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "tools.h"
|
||||||
@ -2312,9 +2312,10 @@ void cDynamicBuffer::Append(const uchar *Data, int Length)
|
|||||||
|
|
||||||
// --- cHashBase -------------------------------------------------------------
|
// --- cHashBase -------------------------------------------------------------
|
||||||
|
|
||||||
cHashBase::cHashBase(int Size)
|
cHashBase::cHashBase(int Size, bool OwnObjects)
|
||||||
{
|
{
|
||||||
size = Size;
|
size = Size;
|
||||||
|
ownObjects = OwnObjects;
|
||||||
hashTable = (cList<cHashObject>**)calloc(size, sizeof(cList<cHashObject>*));
|
hashTable = (cList<cHashObject>**)calloc(size, sizeof(cList<cHashObject>*));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2348,6 +2349,13 @@ void cHashBase::Del(cListObject *Object, unsigned int Id)
|
|||||||
void cHashBase::Clear(void)
|
void cHashBase::Clear(void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size; i++) {
|
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];
|
delete hashTable[i];
|
||||||
hashTable[i] = NULL;
|
hashTable[i] = NULL;
|
||||||
}
|
}
|
||||||
|
11
tools.h
11
tools.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __TOOLS_H
|
||||||
@ -825,9 +825,14 @@ class cHashBase {
|
|||||||
private:
|
private:
|
||||||
cList<cHashObject> **hashTable;
|
cList<cHashObject> **hashTable;
|
||||||
int size;
|
int size;
|
||||||
|
bool ownObjects;
|
||||||
unsigned int hashfn(unsigned int Id) const { return Id % size; }
|
unsigned int hashfn(unsigned int Id) const { return Id % size; }
|
||||||
protected:
|
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:
|
public:
|
||||||
virtual ~cHashBase();
|
virtual ~cHashBase();
|
||||||
void Add(cListObject *Object, unsigned int Id);
|
void Add(cListObject *Object, unsigned int Id);
|
||||||
@ -841,7 +846,7 @@ public:
|
|||||||
|
|
||||||
template<class T> class cHash : public cHashBase {
|
template<class T> class cHash : public cHashBase {
|
||||||
public:
|
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); }
|
T *Get(unsigned int Id) const { return (T *)cHashBase::Get(Id); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user