Clone_oid – Compaq AAR04BCTE User Manual

Page 107

Advertising
background image

eSNMP API Routines

clone_oid

clone_oid

Makes a copy of the OID. This routine does not allocate an OID structure.

Format

oid clone_oid ( oid *new,

oid *oid );

Arguments

new

A pointer to the OID structure that is to receive the copy.

oid

A pointer to the OID structure where the data is to be obtained.

Description

This routine dynamically allocates the buffer and inserts its pointer into the OID

structure received. The caller must explicitly free this buffer.

Point to the OID structure that is to receive the new OID values and call
this routine. Any previous value in the new OID structure is freed (using the

free_oid

routine) and the new values are dynamically allocated and inserted. To

preserve an existing OID structure, initialize the new OID structure with zeros.

If the old OID structure is null or contains a null pointer to its element buffer, a
new OID of [0.0] is generated.

Return Values

Null

An error or the pointer to the OID is returned.

Example

#include <esnmp.h>
OID oid1;
OID oid2;
:
: assume oid1 gets assigned a value
:
memset(&oid2, 0, sizeof(OID));
if (clone_oid(&oid2, &oid1) == NULL)

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

eSNMP API Routines 5–49

Advertising