prg_cmo_define_with_props()

摘要

定义一种带有指定属性集的分类内存对象新类型。

语法

prg_cmo_define_with_props (name, properties)
参数 类型 说明
name const char * 分类内存类型的名称。可以是普通字符串,必要时可包含空格。该名称用于在内存跟踪报告和跟踪语句中标识分类内存对象类型(例如参见 ODB 的 memstats 命令或 prg_mem_stats_print() 函数)。
properties int 要设置的属性(参见详情)。

返回类型

Cmohandle

用于标识新定义内存类型的分类内存对象句柄。在分配单个对象时,可用该句柄调用 prg_cmo_alloc()。

头文件

prg_mem_funcs.h

示例

static Cmohandle					ip_addr_mem_class;
static int					ip_mem_setup = OPC_FALSE;

int		 *ip_addr_ptr;

if (!ip_mem_setup)
	{
	/* One-time ip addresses memory cathegory initialization.*/
	/* No need to pre-clean allocated memory as all ip address fields */
	/* are set after allocation */
	ip_addr_mem_class = prg_cmo_define_with_props ("IP Address Storage",
		PRGC_MEM_DONT_CLEAR);

	ip_mem_setup = OPC_TRUE;
	}

ip_addr_ptr = (int *) prg_cmo_alloc (ip_addr_mem_class, sizeof (int));
*ip_addr_ptr = 0;

详情

该函数的工作方式与 prg_cmo_define() 相同,此外还能为所定义的分类内存对象类型指定属性。

properties 必须为 PRGC_MEM_DONT_CLEAR 或 0。默认情况下,分类内存对象在分配时会清零内存块。但某些类型的操作在拿到对象时会对其进行完整初始化,因此无需清零。设置该属性后,所定义的分类内存对象在分配时将不再清零内存。

用途

创建新的分类内存对象类型,以便通过 prg_cmo_alloc() 函数执行分配。分类内存对象类型可以具有一组自定义属性。

错误

  • 无。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com