[PATCH] EPG data growing without bounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is a problem in VDR where the "X" lines in the epg.data file get
duplicated at every restart of VDR (at least?), leading to an ever
growing file and eventual out of memory errors. The following patch
for 1.3.25 (also applies to .27) seems to fix this. It assumes that
the "Components" in the EPG data structures are supposed to be unique,
so it makes them unique (wrt. all fields - if this assumption is wrong
the tComponent::equals() function should be adapted).

Olaf

--- epg.h.orig	Sat May 28 13:32:36 2005
+++ epg.h	Tue Jul  5 20:33:30 2005
@@ -28,7 +28,8 @@
   char *description;
   cString ToString(void);
   bool FromString(const char *s);
-  };
+  bool equals(uchar ostream, uchar otype, const char *olanguage, const char *odescription);
+};

 class cComponents {
 private:
@@ -39,7 +40,7 @@
   cComponents(void);
   ~cComponents(void);
   int NumComponents(void) const { return numComponents; }
-  void SetComponent(int Index, const char *s);
+  void SetComponent(const char *s);
   void SetComponent(int Index, uchar Stream, uchar Type, const char *Language, const char *Description);
   tComponent *Component(int Index) const { return (Index < numComponents) ? &components[Index] : NULL; }
   };
--- epg.c.orig	Sun May 29 12:19:48 2005
+++ epg.c	Tue Jul  5 20:33:29 2005
@@ -38,6 +38,12 @@
   return n >= 3;
 }

+bool tComponent::equals(uchar ostream, uchar otype, const char *olanguage, const char *odescription)
+{
+    return stream == ostream && type == otype && !strcmp(language, olanguage)
+        && ( (description == NULL && odescription == NULL) || !strcmp(description, odescription) );
+}
+
 // --- cComponents -----------------------------------------------------------

 cComponents::cComponents(void)
@@ -63,8 +69,13 @@
      }
 }

-void cComponents::SetComponent(int Index, const char *s)
+void cComponents::SetComponent(const char *s)
 {
+  for (int i = 0; i < numComponents; i++) {
+    if (!strcmp(s, *components[i].ToString()))
+      return;
+  }
+  int Index = numComponents;
   Realloc(Index);
   components[Index].FromString(s);
 }
@@ -270,7 +281,7 @@
               break;
     case 'X': if (!components)
                  components = new cComponents;
-              components->SetComponent(components->NumComponents(), t);
+              components->SetComponent(t);
               break;
     case 'V': SetVps(atoi(t));
               break;
--- eit.c.orig	Sat May 28 13:35:55 2005
+++ eit.c	Tue Jul  5 20:11:34 2005
@@ -198,8 +198,17 @@
                  if (1 <= Stream && Stream <= 2 && Type != 0) {
                     if (!Components)
                        Components = new cComponents;
+                    int index = 0;
                     char buffer[256];
-                    Components->SetComponent(Components->NumComponents(), cd->getStreamContent(), cd->getComponentType(), I18nNormalizeLanguageCode(cd->languageCode), cd->description.getText(buffer, sizeof(buffer)));
+                    cd->description.getText(buffer, sizeof(buffer));
+                    const char *lang = I18nNormalizeLanguageCode(cd->languageCode);
+                    while (index < Components->NumComponents()) {
+                        tComponent *c = Components->Component(index);
+                        if (c->equals(Stream, Type, lang, buffer))
+                            break;
+                        index++;
+                    }
+                    Components->SetComponent(index, Stream, Type, lang, buffer);
                     }
                  }
                  break;

=== end of patch ===



[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux