123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef __MALLOC_H__
- #define __MALLOC_H__
-
- #ifndef EMULATION
- #define EMULATION 0
- #endif
- #if EMULATION
- #define _MALLOC_SPEC
- #else
- #pragma library c
- #define _MALLOC_SPEC __data
- #endif
- #define MALLOC_MAX_FIRST 0
- #define MAX_BLOCK_SIZE 0x7f
- #define MAX_HEAP_SIZE 0x200
- #define _MAX_HEAP_SIZE (MAX_HEAP_SIZE-1)
- #define ALLOC_FLAG 0x80
- #define HEADER_SIZE 1
- typedef union {
- unsigned char datum;
- struct {
- unsigned count: 7;
- unsigned alloc: 1;
- } bits;
- } _malloc_rec;
- void _initHeap(unsigned char _MALLOC_SPEC *dHeap, unsigned int heapsize);
- _malloc_rec _MALLOC_SPEC *_mergeHeapBlock(_malloc_rec _MALLOC_SPEC *sBlock, unsigned char bSize);
- unsigned char _MALLOC_SPEC *malloc(unsigned char len);
- unsigned char _MALLOC_SPEC *calloc(unsigned char len);
- unsigned char _MALLOC_SPEC *realloc(unsigned char _MALLOC_SPEC *mblock, unsigned char len);
- void free(unsigned char _MALLOC_SPEC *);
- unsigned int memfree(void);
- unsigned int memfreemax(void);
- #endif
|