summaryrefslogtreecommitdiff
path: root/epg.c
diff options
context:
space:
mode:
Diffstat (limited to 'epg.c')
-rw-r--r--epg.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/epg.c b/epg.c
index 18d91fc7..c2d1783d 100644
--- a/epg.c
+++ b/epg.c
@@ -7,7 +7,7 @@
* Original version (as used in VDR before 1.3.0) written by
* Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
*
- * $Id: epg.c 2.6 2010/02/28 14:24:55 kls Exp $
+ * $Id: epg.c 2.7 2011/02/25 15:16:05 kls Exp $
*/
#include "epg.h"
@@ -56,25 +56,34 @@ cComponents::~cComponents(void)
free(components);
}
-void cComponents::Realloc(int Index)
+bool cComponents::Realloc(int Index)
{
if (Index >= numComponents) {
- int n = numComponents;
- numComponents = Index + 1;
- components = (tComponent *)realloc(components, numComponents * sizeof(tComponent));
- memset(&components[n], 0, sizeof(tComponent) * (numComponents - n));
+ Index++;
+ if (tComponent *NewBuffer = (tComponent *)realloc(components, Index * sizeof(tComponent))) {
+ int n = numComponents;
+ numComponents = Index;
+ components = NewBuffer;
+ memset(&components[n], 0, sizeof(tComponent) * (numComponents - n));
+ }
+ else {
+ esyslog("ERROR: out of memory");
+ return false;
+ }
}
+ return true;
}
void cComponents::SetComponent(int Index, const char *s)
{
- Realloc(Index);
- components[Index].FromString(s);
+ if (Realloc(Index))
+ components[Index].FromString(s);
}
void cComponents::SetComponent(int Index, uchar Stream, uchar Type, const char *Language, const char *Description)
{
- Realloc(Index);
+ if (!Realloc(Index))
+ return;
tComponent *p = &components[Index];
p->stream = Stream;
p->type = Type;