From 4011b03fa6a6a7889efea3451a3a125faa72c7fc Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 6 Apr 2011 16:40:47 +0000 Subject: Fixes for kernel stub builds git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3473 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/fs/fat/fs_fat32.c | 21 +++++++++++---------- nuttx/fs/fat/fs_fat32util.c | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'nuttx/fs') diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index e109ca75d..640292145 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -58,6 +58,7 @@ #include #include +#include #include #include #include @@ -286,7 +287,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, * file. */ - ff = (struct fat_file_s *)zalloc(sizeof(struct fat_file_s)); + ff = (struct fat_file_s *)kzalloc(sizeof(struct fat_file_s)); if (!ff) { ret = -ENOMEM; @@ -295,7 +296,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* Create a file buffer to support partial sector accesses */ - ff->ff_buffer = (uint8_t*)malloc(fs->fs_hwsectorsize); + ff->ff_buffer = (uint8_t*)kmalloc(fs->fs_hwsectorsize); if (!ff->ff_buffer) { ret = -ENOMEM; @@ -344,7 +345,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, ssize_t offset = (ssize_t)fat_seek(filep, ff->ff_size, SEEK_SET); if (offset < 0) { - free(ff); + kfree(ff); return (int)offset; } } @@ -356,7 +357,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, */ errout_with_struct: - free(ff); + kfree(ff); errout_with_semaphore: fat_semgive(fs); @@ -402,12 +403,12 @@ static int fat_close(FAR struct file *filep) if (ff->ff_buffer) { - free(ff->ff_buffer); + kfree(ff->ff_buffer); } /* Then free the file structure itself. */ - free(ff); + kfree(ff); filep->f_priv = NULL; return ret; } @@ -1491,7 +1492,7 @@ static int fat_bind(FAR struct inode *blkdriver, const void *data, /* Create an instance of the mountpt state structure */ - fs = (struct fat_mountpt_s *)zalloc(sizeof(struct fat_mountpt_s)); + fs = (struct fat_mountpt_s *)kzalloc(sizeof(struct fat_mountpt_s)); if (!fs) { return -ENOMEM; @@ -1513,7 +1514,7 @@ static int fat_bind(FAR struct inode *blkdriver, const void *data, if (ret != 0) { sem_destroy(&fs->fs_sem); - free(fs); + kfree(fs); return ret; } @@ -1581,9 +1582,9 @@ static int fat_unbind(void *handle, FAR struct inode **blkdriver) if (fs->fs_buffer) { - free(fs->fs_buffer); + kfree(fs->fs_buffer); } - free(fs); + kfree(fs); } fat_semgive(fs); diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 3233ec707..aa327543b 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -56,6 +56,7 @@ #include #include +#include #include #include @@ -626,7 +627,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) /* Allocate a buffer to hold one hardware sector */ - fs->fs_buffer = (uint8_t*)malloc(fs->fs_hwsectorsize); + fs->fs_buffer = (uint8_t*)kmalloc(fs->fs_hwsectorsize); if (!fs->fs_buffer) { ret = -ENOMEM; @@ -724,7 +725,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) return OK; errout_with_buffer: - free(fs->fs_buffer); + kfree(fs->fs_buffer); fs->fs_buffer = 0; errout: fs->fs_mounted = false; -- cgit v1.2.3