Select Git revision
commande.class.php
-
Drosis Nikos authoredDrosis Nikos authored
mm.c 18.46 KiB
/*
* mm.c - Simple allocator based on explicit free lists and
* first fit placement. It uses boundary tags and
* a circular doubly linked list to keep track of
* free blocks.
*
* Each block has a header and footer of the form:
*
* 31 3 2 1 0
* -----------------------------------
* | s s s s ... s s s 0 0 a/f
* -----------------------------------
*
* where s are the meaningful size bits and a/f is set iff the
* block is allocated (0=a/1=f). Every block follows the form:
*
* 31 0
* ----------------
* | Header
* ------------------
* | prev_free_block \
* ---------------- | - Payload when not free
* | next_free_block /
* ------------------
* | Footer
* ----------------
*
* Due to the size of the header and the bytes required to store
* the next and previous pointers, the minsize of a free block MUST
* be 4 words, or 2 DWORDS (16 bytes)
*
* The list has the following form:
*
* begin end
* heap heap
* -----------------------------------------------------------------
* | key | hdr(8:a) | pad | zero or more usr blks | hdr(8:a) |
* -----------------------------------------------------------------
* four | prologue | four | | epilogue |
* bytes | block | bytes | | block |
*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "mm.h"
#include "memlib.h"
/* Team structure */
team_t team = {
/* Team name */
"Daniel Shchur",
/* Full name */
"Daniel Shchur",
/* Email address */
"daniel.shchur@huskers.unl.edu",
"",""
};
/* $begin mallocmacros */
/* Basic constants and macros */
/* You can add more macros and constants in this section */
#define WSIZE 4 /* word size (bytes) */
#define DSIZE 8 /* doubleword size (bytes) */
#define CHUNKSIZE (1<<12) /* initial heap size (bytes) */