beautypg.com

Clone_oct – Compaq AAR04BCTE User Manual

Page 112

background image

eSNMP API Routines
clone_oct

clone_oct

Makes a copy of the data in an

oct

structure. This routine does not allocate an

oct

structure; it allocates the buffer pointed to by the

oct

structure.

Format

oct clone_oct ( oct *new,

oct *old );

Arguments

new

A pointer to the

oct

structure receiving the data.

old

A pointer to the

oct

structure where the data is to be obtained.

Description

The

clone_oct

routine dynamically allocates the buffer, copies the data, and

updates the

oct

structure with the buffer’s address and length. The caller must

free this buffer.

The previous value of the buffer on the new

oct

structure is freed prior to the

new buffer being allocated. If you do not want the old value freed, initialize the
new

oct

structure before cloning.

Return Values

Null

An error occurred. Otherwise, the pointer to the

oct

structure (the first argument) is returned.

Example

#include
OCT octet1;
OCT octet2;
:
: assume octet1 gets assigned a value
:
memset(&octet2, 0, sizeof(OCT));
if (clone_oct(&octet2, &octet1) == NULL)

DPRINTF((WARNING, "It did not work\n"));

5–54 eSNMP API Routines