diff options
author | Christian Wieninger <cwieninger@gmx.de> | 2012-04-06 20:27:04 +0200 |
---|---|---|
committer | Christian Wieninger <cwieninger@gmx.de> | 2012-04-06 20:27:04 +0200 |
commit | 3bd2658c85f00269583259d5912c88f031b9599f (patch) | |
tree | 6f95f40fbaf30b383a16f566d84a0ade7b448cec /createcats.c | |
parent | 65f1e5030f076c530a5a6a37ead43cf7d9d86325 (diff) | |
download | vdr-plugin-epgsearch-3bd2658c85f00269583259d5912c88f031b9599f.tar.gz vdr-plugin-epgsearch-3bd2658c85f00269583259d5912c88f031b9599f.tar.bz2 |
bugtracker #929, bunch of warning fixes, thanks to Joe_D for providing this patch
Diffstat (limited to 'createcats.c')
-rw-r--r-- | createcats.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/createcats.c b/createcats.c index c83866c..e252e35 100644 --- a/createcats.c +++ b/createcats.c @@ -59,6 +59,7 @@ class cReadLine { private: char buffer[MAXPARSEBUFFER]; public: + cReadLine() { buffer[0]=0; } char *Read(FILE *f); }; @@ -106,8 +107,13 @@ class cCat { return; char* newvalue = (char*) malloc(sizeof(char) * (strlen(value)+1)); strcpy(newvalue, value); - values = (char**) realloc(values, sizeof(char*)*(numvalues+1)); - values[numvalues++] = newvalue; + char **tmp = (char**) realloc(values, sizeof(char*)*(numvalues+1)); + if (tmp) { + values=tmp; + values[numvalues++] = newvalue; + } else { + free(newvalue); + } } bool valueexists(char* value) { @@ -143,9 +149,16 @@ class cCats { cCat* add(char* name) { cCat* newCat = new cCat(name); - cats = (cCat**) realloc(cats, sizeof(cCat*)*(numcats+1)); - cats[numcats++] = newCat; - return newCat; + cCat **tmp = (cCat**) realloc(cats, sizeof(cCat*)*(numcats+1)); + if (tmp) + { + cats=tmp; + cats[numcats++] = newCat; + return newCat; + } else { + delete newCat; + return NULL; + } } cCat* get(int i) |