recycle.h
来自「写程序是经常遇到内存不足,这个程序可以自动释放不用的内存」· C头文件 代码 · 共 80 行
H
80 行
/*
______________________________________________________________________________________
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 + =
减小字号Ctrl + -
显示快捷键?