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

📄 rvalloc.h

📁 h.248协议源码
💻 H
字号:
#if (0)
******************************************************************************
Filename:
Description: C/Macro-based allocator
******************************************************************************
                Copyright (c) 1999 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever 
without written prior approval by RADVision LTD..

RADVision LTD. reserves the right to revise this publication and make 
changes without obligation to notify any person of such revisions or 
changes.
******************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
******************************************************************************
#endif

#ifndef RV_ALLOC_H
#define RV_ALLOC_H

#include <stddef.h>

/*$
{type:
	{name: RvAlloc}
	{superpackage: Util}	
	{include: rvalloc.h}
	{description:	
		{p: Describes a generic interface to a dynamic memory allocator.}
		{p: Allocators are used to parameterize memory management function
			for a given algorithm.  By parameterizing the allocator the 
			algorithm is no longer bound to a single memory management 
			methodology.
		}
	}
	{methods:
		{method: RvAlloc* rvAllocConstruct(RvAlloc* a, void* pool, size_t maxSize, void* (*alloc)(void*, size_t), void (*dealloc)(void*, size_t, void*));}
		{method: void rvAllocDestruct(RvAlloc* a);}
		{method: void* rvAllocAllocate(RvAlloc* a, size_t s);}
		{method: void rvAllocDeallocate(RvAlloc* a, size_t s, void* ptr);}
		{method: void* rvAllocGetPool(RvAlloc* a);}
		{method: size_t rvAllocGetMaxSize(RvAlloc* a);}
	}
}
$*/
#if defined(__cplusplus)
extern "C" {
#endif

typedef struct RvAlloc_ {
	void* pool;
	size_t maxSize;
	void* (*alloc)(void* pool, size_t s);
	void (*dealloc)(void* pool, size_t s, void* x);
} RvAlloc;


RvAlloc* rvAllocConstruct(RvAlloc* a, void* pool, size_t maxSize, 
  void* (*alloc)(void*, size_t), void (*dealloc)(void*, size_t, void*));
/*$
{function:
	{name: rvAllocDestruct}	
	{class: RvAlloc}	
	{include: rvalloc.h}
	{description:
		{p: Destruct an allocator object.}
	}
	{proto: void rvAllocDestruct(RvAlloc* a);}
	{params:
		{param: {n: a} {d: A pointer to the allocator.}}
	}
}
$*/
#define rvAllocDestruct(a)
void* rvAllocAllocate(RvAlloc* a, size_t s);
void rvAllocDeallocate(RvAlloc* a, size_t s, void* ptr);

#define rvAllocAllocateObject(a,t)    (t *)rvAllocAllocate(a, sizeof(t))
#define rvAllocDeallocateObject(a,t,o)  if((o) != NULL){ rvAllocDeallocate(a, sizeof(t), (o));(o) = NULL; }

/*$
{function:
	{name: rvAllocGetPool}	
	{class: RvAlloc}	
	{include: rvalloc.h}
	{description:
		{p: Get the allocator's pool.}
	}
	{proto: void* rvAllocGetPool(RvAlloc* a);}
	{params:
		{param: {n: a} {d: A pointer to the allocator.}}
	}
	{returns: A pointer to the pool.}
}
$*/
#define rvAllocGetPool(a)						((a)->pool)
/*$
{function:
	{name: rvAllocGetMaxSize}	
	{class: RvAlloc}	
	{include: rvalloc.h}
	{description:
		{p: Get the maximum size (in bytes) the allocator can allocate.}
	}
	{proto: size_t rvAllocGetMaxSize(RvAlloc* a);}
	{params:
		{param: {n: a} {d: A pointer to the allocator.}}
	}
	{returns: The maximum allocation size.}
}
$*/
#define rvAllocGetMaxSize(a)					((a)->maxSize)

#if defined(__cplusplus)
}
#endif

#endif

⌨️ 快捷键说明

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