CS350 COS
COS
|
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
Go to the source code of this file.
Data Structures | |
struct | Header |
struct | HeapPool |
Macros | |
#define | HEAP_MAGIC 0x8051 |
#define | HEAP_MIN_POOLSIZE (64 - sizeof(Header)) |
#define | HEAP_MAX_POOLSIZE (128*1024 - sizeof(Header)) |
#define | HEAP_POOLS (12) |
#define | PGSIZE 4096 |
#define | HEAP_INCREMENT (PGSIZE / 64) |
#define | ROUNDUP(_x, _n) (((_x) + (_n) - 1) & ~((_n) - 1)) |
Typedefs | |
typedef struct Header | Header |
typedef struct HeapPool | HeapPool |
Functions | |
static int | size_to_idx (size_t sz) |
static void | grow_small (int idx) |
static void * | malloc_small (size_t sz) |
static void | free_small (Header *mem) |
static void * | malloc_large (size_t sz) |
static void | free_large (Header *mem) |
void * | calloc (size_t num, size_t sz) |
void * | malloc (size_t sz) |
void | free (void *mem) |
Variables | |
static HeapPool | pool [HEAP_POOLS] |
static HeapPool | largePool = { 0, 0, (Header *)0, 0x4C000000, 0x4C000000 } |
struct Header |
struct HeapPool |
#define ROUNDUP | ( | _x, | |
_n | |||
) | (((_x) + (_n) - 1) & ~((_n) - 1)) |
void free | ( | void * | mem | ) |
Definition at line 169 of file malloc.c.
|
static |
|
static |
|
static |
Definition at line 67 of file malloc.c.
void * malloc | ( | size_t | sz | ) |
|
static |
|
static |
Definition at line 95 of file malloc.c.
|
static |
|
static |