prg_cmo_define_with_props()
Abstract
Defines a new type of categorized memory object with a set of desired properties.
Syntax
prg_cmo_define_with_props (name, properties)
| Argument | Type | Description |
|---|---|---|
name |
const char * |
Name of the categorized memory type. This can be a general character string, including white space if desired. This name is used to identify the categorized memory object type in memory tracking reports and trace statements (for example, see the memstats command of ODB or the prg_mem_stats_print() function). |
properties |
int |
Properties to set (see Details). |
Return Type
Cmohandle
Categorized memory object handle used to identify the newly defined memory type. This handle can be used to call prg_cmo_alloc() when allocating individual objects.
Header
prg_mem_funcs.h
Example
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;
Details
This function works like prg_cmo_define(), with the addition of the ability to specify properties for the categorized memory object type being defined.
properties must be either PRGC_MEM_DONT_CLEAR or 0. By default, categorized memory objects clear out memory blocks as they are allocated. However, because some types of operations perform complete initialization of the object when they receive it, clearing is not needed. This sets the properties of the categorized memory object being defined to prevent clearing of memory when allocated.
Purpose
Creates a new categorized memory object type so that allocations can be performed via the function prg_cmo_alloc(). The categorized memory object type can have a set of custom properties.
Errors
- None.
Reference
- use
prg_cmo_define()to define a new type of categorized memory object or obtain a categorized memory object handle - use
prg_cmo_alloc()to allocate an object using a categorized memory object handle - use
prg_mem_free()to deallocate a categorized memory object - use
prg_mem_alloc()to allocate generic (non-categorized) memory - use
prg_mem_copy()to copy a block of memory