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

📄 mbrk.c

📁 c库的部分源代码 用惯了操作系统提供的内存api,你是否了解系统的运行机制,这是提供动态内存分配最简单的实现代码 静态的代码库 可用各种c编译
💻 C
字号:
/****************************************************************
	Copyright 1988 Software Development Systems, Inc.

	This is the default mbrk() function, used with malloc()
	and calloc().  This mbrk() will succeed the first time
	it gets a request for a memory section with no more than
	_brksz bytes, and in that case returns the section
	indicated by _brkp,_brksz.  All other times this
	function returns 0.  The code in "start.s" initializes
	_brkp,_brksz to the address and size of the region
	"malloc" declared in the link specification file "spec".
****************************************************************/
#include "alloc.h"
extern void *_brkp;
extern long _brksz;

char *mbrk( long size, long *realsize ) {
    if ( size > _brksz ) return 0;
    *realsize = _brksz;
    _brksz = 0;
    return _brkp; }

⌨️ 快捷键说明

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