#include "yportenv.h"
#ifdef CONFIG_YAFFS_KMALLOC_ALLOCATOR
+/* This is an alternative debug allocator. Don't use for production code. */
void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev)
{
struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev)
{
- return (struct yaffs_tnode *)kmalloc(dev->tnode_size, GFP_NOFS);
+ return kmalloc(dev->tnode_size, GFP_NOFS);
}
void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev)
{
dev = dev;
- return (struct yaffs_obj *)kmalloc(sizeof(struct yaffs_obj));
+ return kmalloc(sizeof(struct yaffs_obj));
}
void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj)
static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev)
{
-
struct yaffs_allocator *allocator =
(struct yaffs_allocator *)dev->allocator;
-
struct yaffs_tnode_list *tmp;
if (!allocator) {
kfree(allocator->alloc_tnode_list->tnodes);
kfree(allocator->alloc_tnode_list);
allocator->alloc_tnode_list = tmp;
-
}
allocator->free_tnodes = NULL;
return YAFFS_OK;
/* make these things */
-
new_tnodes = kmalloc(n_tnodes * dev->tnode_size, GFP_NOFS);
mem = (u8 *) new_tnodes;
* NB If we can't add this to the management list it isn't fatal
* but it just means we can't free this bunch of tnodes later.
*/
-
tnl = kmalloc(sizeof(struct yaffs_tnode_list), GFP_NOFS);
if (!tnl) {
yaffs_trace(YAFFS_TRACE_ERROR,
allocator->alloc_tnode_list = tnl;
}
- yaffs_trace(YAFFS_TRACE_ALLOCATE,"Tnodes added");
+ yaffs_trace(YAFFS_TRACE_ALLOCATE, "Tnodes added");
return YAFFS_OK;
}
static int yaffs_create_free_objs(struct yaffs_dev *dev, int n_obj)
{
struct yaffs_allocator *allocator = dev->allocator;
-
int i;
struct yaffs_obj *new_objs;
struct yaffs_obj_list *list;
list = kmalloc(sizeof(struct yaffs_obj_list), GFP_NOFS);
if (!new_objs || !list) {
- if (new_objs) {
- kfree(new_objs);
- new_objs = NULL;
- }
- if (list) {
- kfree(list);
- list = NULL;
- }
+ kfree(new_objs);
+ new_objs = NULL;
+ kfree(list);
+ list = NULL;
yaffs_trace(YAFFS_TRACE_ALLOCATE,
"Could not allocate more objects");
return YAFFS_FAIL;