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.
null An error or the pointer to the oct structure, the first argument, is returned.
#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"));
Frees the octet.
void free_oct (oct *oct)
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.
#include <esnmp.h> OCT octet; : : assume octet was assigned a value (perhaps with mem2oct() : and we are now finished with it. : free_oct(&octet);
Frees the data on the VARBIND structure. However, this routine does not free the VARBIND structure itself.
void free_varbind_data (varbind *vb)
#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);