diff options
Diffstat (limited to 'libfat')
-rw-r--r-- | libfat/cache.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libfat/cache.c b/libfat/cache.c index 9e8df361..85b7eadf 100644 --- a/libfat/cache.c +++ b/libfat/cache.c @@ -19,47 +19,47 @@ #include <stdlib.h> #include "libfatint.h" -void * libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n) +void *libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n) { - struct libfat_sector *ls; + struct libfat_sector *ls; - for ( ls = fs->sectors ; ls ; ls = ls->next ) { - if ( ls->n == n ) - return ls->data; /* Found in cache */ - } + for (ls = fs->sectors; ls; ls = ls->next) { + if (ls->n == n) + return ls->data; /* Found in cache */ + } - /* Not found in cache */ - ls = malloc(sizeof(struct libfat_sector)); - if ( !ls ) { - libfat_flush(fs); + /* Not found in cache */ ls = malloc(sizeof(struct libfat_sector)); + if (!ls) { + libfat_flush(fs); + ls = malloc(sizeof(struct libfat_sector)); - if ( !ls ) - return NULL; /* Can't allocate memory */ - } + if (!ls) + return NULL; /* Can't allocate memory */ + } - if ( fs->read(fs->readptr, ls->data, LIBFAT_SECTOR_SIZE, n) - != LIBFAT_SECTOR_SIZE ) { - free(ls); - return NULL; /* I/O error */ - } + if (fs->read(fs->readptr, ls->data, LIBFAT_SECTOR_SIZE, n) + != LIBFAT_SECTOR_SIZE) { + free(ls); + return NULL; /* I/O error */ + } - ls->n = n; - ls->next = fs->sectors; - fs->sectors = ls; + ls->n = n; + ls->next = fs->sectors; + fs->sectors = ls; - return ls->data; + return ls->data; } void libfat_flush(struct libfat_filesystem *fs) { - struct libfat_sector *ls, *lsnext; + struct libfat_sector *ls, *lsnext; - lsnext = fs->sectors; - fs->sectors = NULL; + lsnext = fs->sectors; + fs->sectors = NULL; - for ( ls = lsnext ; ls ; ls = lsnext ) { - lsnext = ls->next; - free(ls); - } + for (ls = lsnext; ls; ls = lsnext) { + lsnext = ls->next; + free(ls); + } } |