op_prg_cmo_dealloc()

Abstract

Deallocates a block of categorized memory that was previously allocated.

Note: This KP is a macro call included for backward compatibility only. Use prg_mem_free() in new code.

Syntax

op_prg_cmo_dealloc (ptr)
Argument Type Description
ptr void* Pointer to the categorized memory object to be deallocated.

Return Type

void

No return value.

Example

/* Allocate categorized memory object */
cmo_ptr = op_prg_cmo_alloc (host_cmo, strlen (orig_name) + 1);

/* Use categorized memory */
...

/* Finished with categorized memory, so deallocate */
if (cmo_ptr != OPC_NIL)
	op_prg_cmo_dealloc (cmo_ptr);

Details

Memory that is dynamically allocated should be deallocated if it is no longer useful in the simulation, so that it can be recycled for other purposes. Short-lived data structures that are created during simulation or program execution will build up memory usage if not deallocated, and can cause an unnecessary abort due to lack of memory. The user is responsible for ensuring that NIL or uninitialized pointers are not passed to op_prg_cmo_dealloc(). Other invalid pointers include statically declared memory such as global or temporary function variables.

Purpose

Provides a mechanism for recycling dynamically-allocated memory that has finished serving its purpose in the simulation or program execution.

Errors

  • None.

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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