HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
23.5 slapi_ch_calloc()
Description Allocates space for an array of a number of elements of a specified size.
Syntax
#include "slapi-plugin.h"
char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
Parameters This function takes the following parameters:
Number of elements for which you want to allocate memory.
nelem
Size, in bytes, of the element for which you want to allocate memory.
size
Returns This function returns a pointer to the newly allocated space of memory. If space cannot
be allocated, for example, no more virtual memory exists, the slapd program terminates.
Memory concerns This function terminates the slapd server with an "out of memory" error
message if memory cannot be allocated. You should free the returned pointer by calling
“slapi_build_control()”.
See also
“slapi_ch_free()”
slapi_ch_malloc()
slapi_ch_realloc()
slapi_ch_strdup()
23.6 slapi_ch_free()
Description Frees space allocated by the slapi_ch_malloc(), slapi_ch_realloc(), and
“slapi_ch_calloc()” functions and sets the pointer to NULL. Call this function instead of the
standard free() C function.
Syntax
#include "slapi-plugin.h"
void slapi_ch_free( void **ptr );
Parameters This function takes the following parameter:
Address of the pointer to the block of memory that you want to free. If NULL, no action
occurs.
ptr
Memory concerns The ptr passed to slapi_ch_free() should be the address of a pointer
that was allocated using a slapi call such as slapi_ch_malloc(), “slapi_ch_calloc()”,
slapi_ch_realloc(), or slapi_ch_strdup().
See also
slapi_ch_malloc()
“slapi_ch_calloc()”
slapi_ch_realloc()
slapi_ch_strdup()
23.7 slapi_ch_free_string()
Description This function frees space previously allocated to a string. This function is similar
to “slapi_ch_free()”, but the argument is the address of a string. This helps with compile time
error checking.
Syntax
23.5 slapi_ch_calloc() 207