metal-cos/sys/kern/malloc.c

61 lines
813 B
C
Raw Normal View History

2014-02-12 21:47:13 +00:00
/*
* Copyright (c) 2013-2014 Stanford University
* All rights reserved.
*/
#include <stdarg.h>
#include <stdint.h>
#include <kassert.h>
typedef struct TLSFBlock
2014-02-12 21:47:13 +00:00
{
struct TLSFBlock *prevBlock;
uint64_t size;
// Only valid for free blocks
struct TLSFBlock *prev;
struct TLSFBlock *next;
} TLSFBlock;
2014-02-12 21:47:13 +00:00
typedef struct Heap
2014-02-12 21:47:13 +00:00
{
uint64_t magic;
2014-02-12 21:47:13 +00:00
// Lock
// Debug statistics
uint64_t poolSize;
uint64_t poolAllocs;
// Free list
uint32_t flVector;
uint32_t slVector[FL_SIZE];
struct TLSFBlock *blocks[SL_SIZE][FL_SIZE];
} Heap;
2014-02-12 21:47:13 +00:00
Heap*
Malloc_Create()
2014-02-12 21:47:13 +00:00
{
}
void
Malloc_Destroy(Heap *heap)
2014-02-12 21:47:13 +00:00
{
}
void*
Malloc_Alloc(Heap *heap, uint64_t len)
2014-02-12 21:47:13 +00:00
{
}
void
Malloc_Free(Heap *heap, void *buf)
2014-02-12 21:47:13 +00:00
{
}
bool
Malloc_Realloc(Heap *heap, void *buf, uint64_t newlen)
2014-02-12 21:47:13 +00:00
{
}