⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 malloc.c

📁 实现一个简单的单进程内核,。该内核启用二级虚拟页表映射
💻 C
字号:
/* The 15-410 C Library * malloc.c *  * Zachary Anderson(zra) */#include "mm_malloc.h"#include <stdlib.h>#include <string.h> /* for bzero *//* * Has the mm_malloc library been initialized yet? */static unsigned int inited = 0;/* * wrapper around the mm_malloc library mm_malloc */void *_malloc( size_t __size ){	if( !inited ) {		mm_init();		inited = 1;	}	return mm_malloc( __size );}/* * calloc implimented with mm_malloc library */void *_calloc( size_t __nelt, size_t __eltsize ){	void *new;        if( !inited ) {                mm_init();                 inited = 1;        }	new = mm_malloc( __nelt * __eltsize );	if( !new ) {		return NULL;	}	bzero( new, __nelt * __eltsize );	return new;}/* * wrapper around the mm_malloc library mm_realloc */void *_realloc( void *__buf, size_t __new_size ){        if( !inited ) {		/* have to malloc before realloc =P */		return NULL;        }	return mm_realloc( __buf, __new_size );}/* * wrapper around the mm_malloc library mm_free */void _free( void *__buf ){	if( !inited ) {		/* hmm. not really anything to free. */		return;	}	mm_free( __buf );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -