Cosmetic: captive_shared_cache_map_get_ref(): 'CallBacks' can be 'const'.
authorshort <>
Sat, 13 Sep 2003 06:00:53 +0000 (06:00 +0000)
committershort <>
Sat, 13 Sep 2003 06:00:53 +0000 (06:00 +0000)
captive_shared_cache_map_set_data_valid(): Validate last FileSize-matching page.

src/libcaptive/cc/sharedcachemap.c

index 9f917a6..f1b925e 100644 (file)
@@ -254,7 +254,7 @@ static void captive_shared_cache_map_object_purge(CaptiveSharedCacheMapObject *c
 }
 
 CaptiveSharedCacheMapObject *captive_shared_cache_map_get_ref(FILE_OBJECT *FileObject,
-               const CC_FILE_SIZES *FileSizes,BOOLEAN PinAccess,CACHE_MANAGER_CALLBACKS *CallBacks,VOID *LazyWriterContext)
+               const CC_FILE_SIZES *FileSizes,BOOLEAN PinAccess,const CACHE_MANAGER_CALLBACKS *CallBacks,VOID *LazyWriterContext)
 {
 CaptiveSharedCacheMapObject *captive_shared_cache_map_object;
 
@@ -273,6 +273,7 @@ CaptiveSharedCacheMapObject *captive_shared_cache_map_object;
 
                /* FIXME: When to drop SharedCacheMap?
                 * Currently we never close it.
+                * Fix also CcZeroData() workaround.
                 */
                g_object_ref(captive_shared_cache_map_object);
 
@@ -442,7 +443,14 @@ guint64 now;
        g_return_if_fail(end<=CAPTIVE_ROUND_UP64(captive_shared_cache_map_object->AllocationSize,PAGE_SIZE));
 
        start=CAPTIVE_ROUND_UP64(start,PAGE_SIZE);
-       end=CAPTIVE_ROUND_DOWN64(end,PAGE_SIZE);
+       if (end<captive_shared_cache_map_object->FileSize)
+               end=CAPTIVE_ROUND_DOWN64(end,PAGE_SIZE);
+       else {
+               /* We can validate the last page of the file
+                * even if it does not end on PAGE_SIZE boundary.
+                */
+               end=CAPTIVE_ROUND_UP64(end,PAGE_SIZE);
+               }
        /* We may get end<start here - it is valid to not to validate anything. */
 
        for (now=start;now<end;now+=PAGE_SIZE) {