meminit.c

来自「T-kernel 的extension源代码」· C语言 代码 · 共 86 行

C
86
字号
/* *---------------------------------------------------------------------- *    T-Kernel / Standard Extension * *    Copyright (C) 2006 by Ken Sakamura. All rights reserved. *    T-Kernel / Standard Extension is distributed  *      under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * *    Version:   1.00.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* *	meminit.c (libtkse) * *	Memory allocation library * *	(*) Since _mem_init is called from the startup processing segment, it is always linked. *	   Therefore, if unnecessary processing is added, the program size become larger, *	   regardless of whether malloc is necessary or not. */#include <basic.h>#include <extension/memory.h>#include <extension/errno.h>#include <sys/memalloc.h>LOCAL	VP	getblk( INT nblk, UINT mematr );LOCAL	void	relblk( VP ptr );/* * Memory allocation */LOCAL VP getblk( INT nblk, UINT mematr ){	VP	ptr;	ER	err;	err = tkse_get_mbk(&ptr, nblk, mematr);	if ( err < E_OK ) {		return NULL;	}	return ptr;}/* * Release memory */LOCAL void relblk( VP ptr ){	tkse_rel_mbk(ptr);}/* * Initialize MACB */EXPORT ER _mem_init( UINT mematr, MACB *_macb ){	MACB	*macb = AlignMACB(_macb);	M_STATE	memsts;	ER	err;	/* Initialization of memory allocation management information */	macb->pagesz   = 0;	/* 0 means "disabled". */	macb->mematr   = mematr;	macb->testmode = 0;	macb->getblk   = getblk;	macb->relblk   = relblk;	QueInit(&macb->areaque);	QueInit(&macb->freeque);	/* Obtain memory information */	err = tkse_mbk_sts(&memsts);	if ( err < E_OK ) {		return err;	}	macb->pagesz = (UW)memsts.blksz;	return E_OK;}

⌨️ 快捷键说明

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