diff options
author | Dimitar Petrovski <dimeptr@gmail.com> | 2012-05-13 11:33:27 +0200 |
---|---|---|
committer | Dimitar Petrovski <dimeptr@gmail.com> | 2012-05-18 09:20:35 +0200 |
commit | 4a30d62b0614e2a2af4b862e9ab5c5c471c8d5a5 (patch) | |
tree | e5587f8d35a48161acaf2eba1fc766d43c24e8ea /eepg.c | |
parent | 3b57ef95c261d53f21fb7db1a283cca1aca64f0f (diff) | |
download | vdr-plugin-eepg-4a30d62b0614e2a2af4b862e9ab5c5c471c8d5a5.tar.gz vdr-plugin-eepg-4a30d62b0614e2a2af4b862e9ab5c5c471c8d5a5.tar.bz2 |
applied patch - fix some cppcheck warnings
Diffstat (limited to 'eepg.c')
-rw-r--r-- | eepg.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -74,6 +74,14 @@ static const char *VERSION = "0.0.6pre"; static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data"); +template <class T> T REALLOC(T Var, size_t Size) +{ + T p = (T)realloc(Var, Size); + if (!p) + free(Var); + return p; +} + using namespace std; const char *optPats[] = { @@ -429,7 +437,7 @@ static bool load_freesat_file (int tableid, const char *filename) int i = table_size[tableid][from_char]++; tables[tableid][from_char] = - (struct hufftab *) realloc (tables[tableid][from_char], (i + 1) * sizeof (tables[tableid][from_char][0])); + (struct hufftab *) REALLOC (tables[tableid][from_char], (i + 1) * sizeof (tables[tableid][from_char][0])); tables[tableid][from_char][i].value = bin; tables[tableid][from_char][i].next = to_char; tables[tableid][from_char][i].bits = bin_len; @@ -620,7 +628,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) lastch = nextCh; if (p >= uncompressed_len) { uncompressed_len += 10; - uncompressed = (char *) realloc (uncompressed, uncompressed_len + 1); + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); } uncompressed[p++] = nextCh; uncompressed[p] = 0; @@ -639,7 +647,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) if (nextCh != STOP && nextCh != ESCAPE) { if (p >= uncompressed_len) { uncompressed_len += 10; - uncompressed = (char *) realloc (uncompressed, uncompressed_len + 1); + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); } uncompressed[p++] = nextCh; uncompressed[p] = 0; @@ -1438,7 +1446,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse LogI(5, prep("DEBUG: Textnr %i, Lasttxt %i."), ST->TextNr, ST->LastTextNr); int SummaryLength = ST->Textlength; - Text = (unsigned char *) realloc (Text, SummaryLength + TotLength); + Text = (unsigned char *) REALLOC (Text, SummaryLength + TotLength); if (Text == NULL) { LogI(0, prep("Summaries memory allocation error.")); return 0; //empty text @@ -1449,7 +1457,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse LastTextBlock = ((ST->LastTextNr == 0) || (ST->TextNr >= ST->LastTextNr)); } while (!LastTextBlock); - Text = (unsigned char *) realloc (Text, 1 + TotLength); //allocate 1 extra byte + Text = (unsigned char *) REALLOC (Text, 1 + TotLength); //allocate 1 extra byte Text[TotLength] = '\0'; //terminate string by NULL char LogD(5, prep("DEBUG: Full Text:%s."), Text); @@ -2015,7 +2023,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) //since the data has to be stored anyway; summaries do not seem to have channelid included, so storing titles and separately storing summaries will not work... //GetEventId only works for a specific Schedule for a specific ChannelId.... buffer[TableIdExtension] = - (unsigned char *) realloc (buffer[TableIdExtension], SectionLength - 9 + bufsize[TableIdExtension]); + (unsigned char *) REALLOC (buffer[TableIdExtension], SectionLength - 9 + bufsize[TableIdExtension]); memcpy (buffer[TableIdExtension] + bufsize[TableIdExtension], Data + 8, SectionLength - 9); //append new section bufsize[TableIdExtension] += SectionLength - 9; if (TBH->SectionNumber >= TBH->LastSectionNumber) { @@ -4489,6 +4497,7 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); + closedir(ConfigDir); new cEEpgHandler(); return true; |