# Digital TCP/IP Services for OpenVMS
eSNMP Programming and Reference

Previous | Contents

The previous value of the buffer on the new oct structure is freed prior to the new buffer being allocated. Be sure that the original value for the new ptr is zeroed before cloning, unless you want the old value freed.

## Return Values

> null | An error or the pointer to the oct structure, the first argument, is returned.

## Example

>     #include <esnmp.h>
>     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"));

# free_oct

> Frees the octet.

## Format

> ### void free_oct (oct *oct)

## DESCRIPTION

> This routine frees the dynamically allocated buffer and zeros the pointer and length on the oct structure. If the buffer is already null this routine does nothing.

> > Note

> > This routine does not deallocate the oct structure; instead the buffer that it points to is deallocated.

## Example

>     #include <esnmp.h>
>     OCT octet;
>     :
>     : assume octet was assigned a value (perhaps with mem2oct()
>     : and we are now finished with it.
>     :
>     free_oct(&octet);

# free_varbind_date

> Frees the data on the VARBIND structure. However, this routine does not free the VARBIND structure itself.

## Format

> ### void free_varbind_data (varbind *vb)

## Example

>     #include <esnmp.h>
>     VARBIND *vb;

>     vb = (VARBIND*)malloc(sizeof(VARBIND));

>     ... initialized varbind data, perhaps with mem2oct() and
>         instance2oid().  You are now finish with it.

>     free_varbind_data(vb);
>     free(vb);

Index | Contents