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

📄 smalloc.c

📁 T-kernel 的extension源代码
💻 C
字号:
/* *---------------------------------------------------------------------- *    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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -