op_prg_list_transfer()
Abstract
Copies the contents of a source list into a destination list (source elements allocated by non-Riverbed APIs).
Note: This KP is a macro call included for backward compatibility only. Use prg_list_transfer() in new code.
Syntax
op_prg_list_transfer (from_list_ptr, to_list_ptr, elem_size)
| Argument | Type | Description |
|---|---|---|
from_list_ptr |
PrgT_List * |
Pointer to the list to copy from. |
to_list_ptr |
PrgT_List * |
Pointer to the list to copy to. |
elem_size |
size_t |
Size of elements to copy. |
Return Type
void
No return value.
Example
/* Note: src_list_ptr points to the previously */
/* initialized and populated list of ElemT_Type. */
typedef struct {...} ElemT_Type;
PrgT_List *dest_list_ptr;
/* allocate and initialize new list for copy */
dest_list_ptr = op_prg_list_create();
op_prg_list_transfer (src_list_ptr, dest_list_ptr, sizeof (ElemT_Type));
Details
This function clears the destination list, then copies all elements from the source list to the destination list. Copying begins with the first element in the source list.
Note: This KP is MT unsafe, as described in “Multi-Threading Safety“ on page 11. Access to shared lists must be externally serialized.
Purpose
Provides a mechanism to copy elements of a fixed size from one linked list to another. This KP can be used when the elements were not allocated via known methods such as op_prg_mem_alloc(), op_prg_str_decomp(), or op_prg_gdf_read().
Errors
- Program Abort: Segmentation violation. (due to invalid list pointer or malformed list)
- Recoverable Error: Unable to allocate memory for Prg list.
Reference
- Use the KP op_prg_list_elems_copy() to copy a source list whose elements were allocated by Riverbed memory allocation routines