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

📄 recycle.h

📁 写程序是经常遇到内存不足,这个程序可以自动释放不用的内存
💻 H
字号:
/*
______________________________________________________________________________________

					Designed by: 
					Niraj Kedar,
					Systems Engineer,
					L&T Infotech Ltd,
					Bangalore, India.

					e-mail: nirajkedar@yahoo.com

					Date:	July, 2001.

______________________________________________________________________________________
*/

#ifndef __RECYCLE__
#define __RECYCLE__

// enables or disables the print messages on the screen
#define ENABLE_PRINT

// type of allocation
#define MALLOC_SUCCESS 	0	// nornal
#define MALLOC_FAIL		-1	// for sending data out of scope
#define OUT_OF_SCOPE    -2	// for all failure conditions

// the application's enum returning success should have this value
#define SET_SUCCESS_VAL MALLOC_SUCCESS

// typedefs
typedef unsigned long 	size;
typedef signed short 	Alloc_Status;
typedef void*			func_scope;
typedef signed int		RETURN_E;


// set the function scope
#define SET_FN_SCOPE(name) \
	func_scope fn_scope = name

// get function scope
#define GET_FN_SCOPE fn_scope


// return from a function.
#define RETURN(retval) \
	POP(GET_FN_SCOPE, retval); \
	return retval


// stack handle
typedef struct STACK_HANDLE
{
    unsigned short  size;
    struct STACK*   pTopNode;
    struct STACK*   pBottomNode;

}StkHandle;

// declare the stack handle
#define DECL_STACK_HANDLE \
	StkHandle stk_handle

// initialize the stack handle
#define MEMSET_STACK_HANDLE \
	memset(&stk_handle, 0x00, sizeof(StkHandle));

// allocate memory
Alloc_Status Allocate(size size, void** pMem, 
	func_scope fn_scope, Alloc_Status al_outOfScp);


// Replace the "malloc" here with your memory allocating system call. 
// The syntax should be same.
#define ALLOC_MEM(mem_size) \
	malloc(mem_size)

#endif

⌨️ 快捷键说明

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