summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/input/input_dvd.c23
-rw-r--r--src/input/input_file.c29
-rw-r--r--src/input/input_vcd.c20
3 files changed, 32 insertions, 40 deletions
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index 65d31e06a..28c20ded7 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_dvd.c,v 1.31 2001/10/08 12:52:49 jkeil Exp $
+ * $Id: input_dvd.c,v 1.32 2001/10/08 18:06:34 jkeil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -602,13 +602,12 @@ static mrl_t **dvd_plugin_get_dir (input_plugin_t *this_gen,
if (!strcasecmp (&this->filelist[i][nLen-4], ".VOB")) {
char str[1024];
- if(nFiles2 >= this->mrls_allocated_entries
- || this->mrls_allocated_entries == 0) {
+ if(nFiles2 >= this->mrls_allocated_entries) {
+ ++this->mrls_allocated_entries;
+ /* note: 1 extra pointer for terminating NULL */
+ this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(mrl_t*));
this->mrls[nFiles2] = (mrl_t *) xmalloc(sizeof(mrl_t));
}
- else {
- memset(this->mrls[nFiles2], 0, sizeof(mrl_t));
- }
if(this->mrls[nFiles2]->mrl) {
this->mrls[nFiles2]->mrl = (char *)
@@ -647,13 +646,9 @@ static mrl_t **dvd_plugin_get_dir (input_plugin_t *this_gen,
/*
* Freeing exceeded mrls if exists.
*/
- if(*nEntries > this->mrls_allocated_entries)
- this->mrls_allocated_entries = *nEntries;
- else if(this->mrls_allocated_entries > *nEntries) {
- while(this->mrls_allocated_entries > *nEntries) {
- MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
- free(this->mrls[this->mrls_allocated_entries--]);
- }
+ while(this->mrls_allocated_entries > *nEntries) {
+ MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
+ free(this->mrls[this->mrls_allocated_entries--]);
}
/*
@@ -788,8 +783,8 @@ input_plugin_t *init_input_plugin (int iface, config_values_t *config) {
check_solaris_vold_device(this);
#endif
- this->mrls = (mrl_t **) xmalloc(sizeof(mrl_t));
this->mrls_allocated_entries = 0;
+ this->mrls = xmalloc(sizeof(mrl_t*));
this->mrl = NULL;
this->config = config;
diff --git a/src/input/input_file.c b/src/input/input_file.c
index 128d2781e..f8be3e342 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_file.c,v 1.24 2001/10/05 17:36:28 jkeil Exp $
+ * $Id: input_file.c,v 1.25 2001/10/08 18:06:34 jkeil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -572,8 +572,9 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen,
*/
for(i = 0; i < num_dir_files; i++) {
- if(num_files >= this->mrls_allocated_entries
- || this->mrls_allocated_entries == 0) {
+ if(num_files >= this->mrls_allocated_entries) {
+ ++this->mrls_allocated_entries;
+ this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(mrl_t*));
this->mrls[num_files] = (mrl_t *) xmalloc(sizeof(mrl_t));
}
else
@@ -589,8 +590,9 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen,
*/
for(i = 0; i < num_hide_files; i++) {
- if(num_files >= this->mrls_allocated_entries
- || this->mrls_allocated_entries == 0) {
+ if(num_files >= this->mrls_allocated_entries) {
+ ++this->mrls_allocated_entries;
+ this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(mrl_t*));
this->mrls[num_files] = (mrl_t *) xmalloc(sizeof(mrl_t));
}
else
@@ -606,8 +608,9 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen,
*/
for(i = 0; i < num_norm_files; i++) {
- if(num_files >= this->mrls_allocated_entries
- || this->mrls_allocated_entries == 0) {
+ if(num_files >= this->mrls_allocated_entries) {
+ ++this->mrls_allocated_entries;
+ this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(mrl_t*));
this->mrls[num_files] = (mrl_t *) xmalloc(sizeof(mrl_t));
}
else
@@ -643,13 +646,9 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen,
/*
* Freeing exceeded mrls if exists.
*/
- if(num_files > this->mrls_allocated_entries)
- this->mrls_allocated_entries = num_files;
- else if(this->mrls_allocated_entries > num_files) {
- while(this->mrls_allocated_entries > num_files) {
- MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
- free(this->mrls[this->mrls_allocated_entries--]);
- }
+ while(this->mrls_allocated_entries > num_files) {
+ MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
+ free(this->mrls[this->mrls_allocated_entries--]);
}
/*
@@ -777,7 +776,7 @@ input_plugin_t *init_input_plugin (int iface, config_values_t *config) {
this->mrl = NULL;
this->config = config;
- this->mrls = (mrl_t **) xmalloc(sizeof(mrl_t));
+ this->mrls = (mrl_t **) xmalloc(sizeof(mrl_t*));
this->mrls_allocated_entries = 0;
return (input_plugin_t *) this;
diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c
index aeb2118f0..c596510f2 100644
--- a/src/input/input_vcd.c
+++ b/src/input/input_vcd.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_vcd.c,v 1.26 2001/10/07 22:31:20 guenter Exp $
+ * $Id: input_vcd.c,v 1.27 2001/10/08 18:06:34 jkeil Exp $
*
*/
@@ -987,8 +987,10 @@ static mrl_t **vcd_plugin_get_dir (input_plugin_t *this_gen,
memset(&mrl, 0, sizeof (mrl));
sprintf(mrl, "vcd://%d",i);
- if((i-1) >= this->mrls_allocated_entries
- || this->mrls_allocated_entries == 0) {
+ if((i-1) >= this->mrls_allocated_entries) {
+ ++this->mrls_allocated_entries;
+ /* note: 1 extra pointer for terminating NULL */
+ this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(mrl_t*));
this->mrls[(i-1)] = (mrl_t *) xmalloc(sizeof(mrl_t));
}
else {
@@ -1017,13 +1019,9 @@ static mrl_t **vcd_plugin_get_dir (input_plugin_t *this_gen,
/*
* Freeing exceeded mrls if exists.
*/
- if(*nEntries > this->mrls_allocated_entries)
- this->mrls_allocated_entries = *nEntries;
- else if(this->mrls_allocated_entries > *nEntries) {
- while(this->mrls_allocated_entries > *nEntries) {
- MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
- free(this->mrls[this->mrls_allocated_entries--]);
- }
+ while(this->mrls_allocated_entries > *nEntries) {
+ MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
+ free(this->mrls[this->mrls_allocated_entries--]);
}
this->mrls[*nEntries] = NULL;
@@ -1140,7 +1138,7 @@ input_plugin_t *init_input_plugin (int iface, config_values_t *config) {
this->device = config->lookup_str(config, "vcd_device", CDROM);
- this->mrls = (mrl_t **) xmalloc(sizeof(mrl_t));
+ this->mrls = (mrl_t **) xmalloc(sizeof(mrl_t*));
this->mrls_allocated_entries = 0;
this->fd = -1;