资源简介
资源包括:lab说明指导、lab实现代码及解析(在代码注释中)、lab笔记(note文件中)、lab注意事项等,分享给大家
代码片段和文件信息
/*
* mm-naive.c - The fastest least memory-efficient malloc package.
*
* In this naive approach a block is allocated by simply incrementing
* the brk pointer. A block is pure payload. There are no headers or
* footers. Blocks are never coalesced or reused. Realloc is
* implemented directly using mm_malloc and mm_free.
*
* NOTE TO STUDENTS: Replace this header comment with your own header
* comment that gives a high level description of your solution.
*/
#include
#include
#include
#include
#include
#include “mm.h“
#include “memlib.h“
/*********************************************************
* NOTE TO STUDENTS: Before you do anything else please
* provide your team information in the following struct.
********************************************************/
team_t team = {
/* Your student_id */
“16307130350“
/* Your full name */
“王明霞“
/* Your email address */
“16307130350@fudan.edu.cn“
/* leave blank */
““
/* leave blank */
““
};
/* single word (4) or double word (8) alignment */
#define ALIGNMENT 8
/* rounds up to the nearest multiple of ALIGNMENT */
#define ALIGN(size) (((size) + (ALIGNMENT-1)) & ~0x7)
#define SIZE_T_SIZE (ALIGN(sizeof(size_t)))
#define WSIZE 4
#define DSIZE 8
#define CHUNKSIZE (1<<12) //extend heap by this amount(bytes)
#define MAX(xy) ((x)>(y)?(x):(y))
#define PACK(sizealloc) ((size) | (alloc)) //pack a size and allocated bit into a word
#define GET(p) (*(unsigned int *)(p)) //read and write a word at address p
#define PUT(pval) (*(unsigned int *)(p) = (val))
#define GET_SIZE(p) (GET(p) & ~0x7)
#define GET_ALLOC(p) (GET(p) & 0x1)
#define HDRP(bp) ((char *)(bp)-WSIZE)
#define FTRP(bp) ((char *)(bp)+GET_SIZE(HDRP(bp))-DSIZE) /*合并方式采取带边界标记的合并*/
/* Compute address of next and previous blocks*/
#define NEXT_BLKP(bp) ((char *)(bp)+GET_SIZE(((char *)(bp)-WSIZE)))
#define PREV_BLKP(bp) ((char *)(bp)-GET_SIZE(((char *)(bp)-DSIZE)))
#define PREV_linkNODE_RP(bp) ((char*)(bp)) /*bp的前一个node:pred*/
#define NEXT_linkNODE_RP(bp) ((char*)(bp)+WSIZE) /*bp的后一个node:succ*/
static void *extend_heap(size_t words);
static void *coalesce(void *bp);
inline char *find_free_list_header(size_t size);
inline void delete_from_list(char *p);
inline void insert_to_link(char *p);
static void place(void *bpsize_t asize);
static void* find_fit(size_t size);
void* memcpy_new(void *Dest const void *Src size_t Count);
static void *realloc_coalesce(void *bp size_t newSize int *bp_not_change);
static void realloc_place(void *bpsize_t asize);
static char *heap_listp = NULL;
static char *free_list_start = NULL;
/*
* mm_init - initialize the malloc package.
*/
int mm_init(void){
if((heap_listp = mem_sbrk(14*WSIZE))==(void *)-1) //使用mem_sbrk请求额外的堆处理器
return -1;
/* 使用简单分离存储 */
PUT(heap_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-06 11:46 malloclab全套资料及参考答案\
文件 77983 2018-11-06 11:39 malloclab全套资料及参考答案\malloclab.pdf
文件 14110 2018-11-06 11:39 malloclab全套资料及参考答案\mm_5.0.c
文件 16401 2018-11-06 11:39 malloclab全套资料及参考答案\mm_best_untilnow.c
文件 2423 2018-11-06 11:39 malloclab全套资料及参考答案\mm_initial (2).c
文件 883371 2018-11-06 11:40 malloclab全套资料及参考答案\report.docx
文件 13238 2018-11-06 11:39 malloclab全套资料及参考答案\standard.c
相关资源
- VC下使用画图库graphics.h
- BAT大牛亲授基于ElasticSearch的搜房网实
- ics lab8 perflab性能优化实验
- STMicroelectronics STM32及STM8全系列Altium
- graphics包包含graphics.lib.rar
- Zabbix CIICSO3750 监控模板
- 千锋2018elasticsearch笔记.docx
- 使用Qt实现可编辑的画图程序
- 2018年最新ElasticSearch6实战教程
- Qt绘制编辑移动矢量图形
- Foundations Of 3D Computer Graphics (高清P
- WinCC-Graphics.zip
- cocos2dx模仿人要慌绳子的物理小demo
- vicsek模型的Qt实现
- Ericsson的moshell命令大全
- elasticsearch聚合后分页
- COMSOL Multiphysics 5.0破解license
- elasticsearch视频教程.txt
- roboticsvisionandcontrolpdf.txt
- 千锋最新elasticsearch6实战教程资料.z
- 黑果显卡驱动NvidiaGraphicsFixup.kext V1.
- Elasticsearch实战完整书签.pdf
- ANSYS Electronics 19.0 Suite x64 Crack
- QT GraphicsView
- COMSOL+Multiphysics-抛物型方程求解热传导
- GSDML-V2.1-ABB-Robotics-PNSW-Device-20120209
- spring boot cloud实战租房网平台(视频和
- Yearbook of World Electronics Data 2016
- 基于SimMechanics的三自由度并联机器人
- 计算机图形学,内含DDA画直线,画圆
评论
共有 条评论