📄 uffs_mem.h
字号:
#ifndef UFFS_MEM_H#define UFFS_MEM_H
#include "uffs/uffs_device.h"
#ifdef __cplusplusextern "C"{#endif
#define HEAP_HASH_BIT 6 /* hash table bit */
#define HEAP_HASH_SIZE (1 << (HEAP_HASH_BIT - 1)) /* hash table size */
#define HEAP_HASH_MASK (HEAP_HASH_SIZE - 1) /* hash table mask */
#define GET_HASH_INDEX(p) ((((u32)(p)) >> 2) & HEAP_HASH_MASK)
/* memory alloc node */
typedef struct _heap_mm_node{
int task_id; /* who alloc this block? it's the caller's task id */
struct _heap_mm_node * next; /* point to next node */
void *p; /* point to allocated block */
int size; /* block size */
} HEAP_MM;
typedef HEAP_MM* HASHTBL;
/** uffs native memory allocator */
typedef struct uffs_memAllocatorSt {
HASHTBL tbl[HEAP_HASH_SIZE];
void * (*malloc)(struct uffs_memAllocatorSt *mem, unsigned int size);
void * (*realloc)(struct uffs_memAllocatorSt *mem, void *p, unsigned int size);
void * (*calloc)(struct uffs_memAllocatorSt *mem, unsigned int num, unsigned int size);
void (*free)(struct uffs_memAllocatorSt *mem, void *p);
int count;
int maxused;
} uffs_memAllocator;
/** \note: uffs_InitHeapMemory should be called before using native memory allocator on each device */
void uffs_InitHeapMemory(void *addr, int size);
URET uffs_initNativeMemAllocator(uffs_Device *dev);
int uffs_releaseNativeMemAllocator(uffs_Device *dev);
#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -