aboutsummaryrefslogtreecommitdiff
path: root/src/file_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_win.c')
-rw-r--r--src/file_win.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/file_win.c b/src/file_win.c
index 15d2a61..b4c4730 100644
--- a/src/file_win.c
+++ b/src/file_win.c
@@ -12,7 +12,7 @@ static const bh_io_table_t bh_file_table = {
(bh_off_t (*)(struct bh_io_s *)) bh_file_tell_base,
(bh_off_t (*)(struct bh_io_s *)) bh_file_available_base,
(void (*)(struct bh_io_s *)) bh_file_clear_base,
- (void (*)(struct bh_io_s *)) bh_file_destroy
+ (void (*)(struct bh_io_s *)) bh_file_destroy_base
};
bh_file_t *bh_file_new(const char *path)
@@ -31,13 +31,6 @@ bh_file_t *bh_file_new(const char *path)
return result;
}
-void bh_file_free(bh_file_t *file)
-{
- /* Destroy file object and free allocated memory */
- bh_file_destroy(file);
- free(file);
-}
-
int bh_file_init(bh_file_t *file,
const char *path)
{
@@ -45,20 +38,23 @@ int bh_file_init(bh_file_t *file,
if (!path)
return BH_INVALID;
+ /* Initialize underlying io object */
+ bh_io_init(&file->base, &bh_file_table, 1);
+
/* Fill file structure information */
file->handle = INVALID_HANDLE_VALUE;
file->mode = BH_IO_NONE;
file->path = strdup(path);
- file->base.table = &bh_file_table;
return BH_OK;
}
-void bh_file_destroy(bh_file_t *file)
+void bh_file_destroy_base(bh_file_t *file)
{
/* Close the file and free allocated memory */
bh_file_close(file);
free(file->path);
+ bh_io_destroy_base(&file->base);
}
int bh_file_open_base(bh_file_t *file,