smalloc.c

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

C
112
字号
/* *---------------------------------------------------------------------- *    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. * *---------------------------------------------------------------------- *//* *	smalloc.c (libtkse) * *	Allocation of non-resident shared memory * *	For application */#include "libtkse.h"#include <extension/memory.h>Inline	void	Smeminit( void );#ifndef SMALLOCTESTEXPORT MACB	_Smacb;		/* Smalloc management information */#elseIMPORT MACB	_Smacb;		/* Smalloc management information */#endifInline void Smeminit( void ){	if ( AlignMACB(&_Smacb)->pagesz == 0U ) {		(void)_mem_init(M_COMMON, &_Smacb);	}}#ifndef SMALLOCTESTEXPORT void* Smalloc( size_t size ){	void	*p;	MEMLOCK( return NULL )	Smeminit();	p = _mem_malloc(size, &_Smacb);	MEMUNLOCK()	return p;}EXPORT void* Scalloc( size_t nmemb, size_t size ){	void	*p;	MEMLOCK( return NULL )	Smeminit();	p = _mem_calloc(nmemb, size, &_Smacb);	MEMUNLOCK()	return p;}EXPORT void* Srealloc( void *ptr, size_t size ){	void	*p;	MEMLOCK( return NULL )	Smeminit();	p = _mem_realloc(ptr, size, &_Smacb);	MEMUNLOCK()	return p;}EXPORT void Sfree( void *ptr ){	MEMLOCK( return )	Smeminit();	_mem_free(ptr, &_Smacb);	MEMUNLOCK()}#else /* SMALLOCTEST */EXPORT void Smalloctest( int mode ){	MEMLOCK( return )	Smeminit();	_mem_malloctest(mode, &_Smacb);	MEMUNLOCK()}EXPORT BOOL Smalloccheck( void *ptr ){	BOOL	b;	MEMLOCK( return FALSE )	Smeminit();	b = _mem_malloccheck(ptr, &_Smacb);	MEMUNLOCK()	return b;}#endif /* SMALLOCTEST */

⌨️ 快捷键说明

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