Show Table of Contents
Chapter 23. Functions for Managing Memory
This chapter contains reference information on routines for managing memory, such as allocating and freeing memory.
Table 23.1. Memory Management Routines
| Function | Description |
|---|---|
| slapi_ch_array_add() | Adds a new array. |
| slapi_ch_array_free() | Frees an existing array. |
| slapi_ch_bvdup() | Makes a copy of an existing berval structure. |
| slapi_ch_bvecdup() | Makes a copy of an array of existing berval structures. |
| slapi_ch_calloc() | Allocates space for an array of a number of elements of a specified size. |
| slapi_ch_free() | Frees space allocated by the slapi_ch_malloc(), slapi_ch_realloc(), and slapi_ch_calloc() functions. |
| slapi_ch_free_string() | Frees space previously allocated to a string. |
| slapi_ch_malloc() | Allocates space in memory. |
| slapi_ch_realloc() | Changes the size of a block of allocated memory. |
| slapi_ch_smprintf() | Creates, formats, and returns a given string. |
| slapi_ch_strdup() | Makes a copy of an existing string. |
23.1. slapi_ch_array_add()
Adds the given string to the given null-terminated array.
If the array is
NULL, then the function creates a new array.
Then use slapi_ch_array_free() to free the array.
For example:
char **array = NULL;
...
slapi_ch_array_add(&array, slapi_ch_strdup("some string"));
...
slapi_ch_array_free(array);Syntax
#include "slapi-plugin.h" void slapi_ch_array_add(char ***array, char *string);
Parameters
This function takes the following parameters:
|
array
| Pointer to the array to be freed. If this parameter is NULL, then the function creates a new array. |
|
string
| The string to add to the array. |

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.