beautypg.com

Clone_buf – Compaq AAR04BCTE User Manual

Page 109

background image

eSNMP API Routines

clone_buf

clone_buf

Duplicates a buffer in a dynamically allocated space.

Format

char clone_buf ( char *str,

int *len );

Arguments

str

A pointer to the buffer to be duplicated.

len

The number of bytes to be copied.

Description

One extra byte is always allocated at the end and is filled with zeros. If the

length is less than zero, the duplicate buffer length is set to zero. A buffer pointer
is always returned, unless there is a

malloc

error.

Return Values

Null

A

malloc

error. Otherwise, the pointer to the

allocated buffer that contains a copy of the
original buffer is returned.

Example

#include
char *str = "something nice";
char *copy;
copy = clone_buf(str, strlen(str));

eSNMP API Routines 5–51