changeset 61:6b7520caf9a1 src

fix stupid bug: test if the buffer is there before using it simplify initialization
author mroi
date Sat, 13 Jul 2002 20:42:55 +0000
parents 30995ad032cf
children 5ce99871a73f
files read_cache.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/read_cache.c	Fri Jul 12 15:46:44 2002 +0000
+++ b/read_cache.c	Sat Jul 13 20:42:55 2002 +0000
@@ -345,7 +345,6 @@
     dvdnav_read_cache_clear(self);
     for (i = 0; i < READ_CACHE_CHUNKS; i++) {
       self->chunk[i].cache_buffer = NULL;
-      self->chunk[i].cache_block_count = 0;
       self->chunk[i].usage_count = 0;
     }
   }
@@ -381,7 +380,6 @@
    return;
    
   for (i = 0; i < READ_CACHE_CHUNKS; i++) {
-    self->chunk[i].cache_start_sector = -1;
     self->chunk[i].cache_valid = 0;
   }
 }
@@ -414,7 +412,8 @@
   /* find a free cache chunk that best fits the required size */
   use = -1;
   for (i = 0; i < READ_CACHE_CHUNKS; i++)
-    if (self->chunk[i].usage_count == 0 && self->chunk[i].cache_malloc_size >= block_count &&
+    if (self->chunk[i].usage_count == 0 && self->chunk[i].cache_buffer &&
+        self->chunk[i].cache_malloc_size >= block_count &&
         (use == -1 || self->chunk[use].cache_malloc_size > self->chunk[i].cache_malloc_size))
       use = i;