From patchwork Thu Jul 7 18:55:35 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olaf Titz X-Patchwork-Id: 11939 Received: from quechua.inka.de ([193.197.184.2] helo=mail.inka.de ident=mail) by www.linuxtv.org with esmtp (Exim 4.34) id 1DqbYg-0003lO-Mq for vdr@linuxtv.org; Thu, 07 Jul 2005 20:57:14 +0200 Received: from bigred.inka.de (uucp@) by mail.inka.de with local-bsmtp id 1DqbYc-00054M-00; Thu, 07 Jul 2005 20:57:10 +0200 Received: from localhost by bigred.inka.de with local id 1DqbX5-0008H4-00; Thu, 07 Jul 2005 20:55:35 +0200 To: vdr@linuxtv.org Organization: private Linux site, southern Germany Cc: From: Olaf Titz Date: Thu, 07 Jul 2005 20:55:35 +0200 Message-ID: Subject: [vdr] [PATCH] EPG data growing without bounds X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2005 18:57:14 -0000 Status: O X-Status: X-Keywords: X-UID: 3467 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 === end of patch === --- 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;