Chapter 35. Functions for Managing Parameter Block

This chapter contains reference information on parameter block routines.

Table 35.1. Parameter Block Routines

Function Description
slapi_pblock_destroy() Frees a pblock from memory.
slapi_pblock_get() Gets the value from a pblock.
Section 35.3, “slapi_pblock_init()” Initializes an existing parameter block so that it can be reused.
slapi_pblock_new() Creates a new pblock.
slapi_pblock_set() Sets the value of a pblock.

35.1. slapi_pblock_destroy()

Frees the specified parameter block from memory.
Syntax

#include "slapi-plugin.h"
void slapi_pblock_destroy( Slapi_PBlock *pb );

Parameters

This function takes the following parameter:

pb
Parameter block that you want to free.
Memory Concerns

The parameter block that you wish to free must have been created using slapi_pblock_new(). Use of this function with pblock allocated on the stack (for example, Slapi_PBlock pb;) or using another memory allocator is not supported and may lead to memory errors and memory leaks. For example:

Slapi_PBlock *pb = malloc(sizeof(Slapi_PBlock));
After calling this function, you should set the pblock pointer to NULL to avoid reusing freed memory in your function context, as in the following:
slapi_pblock_destroy(pb);

pb = NULL;
If you reuse the pointer in this way, it makes it easier to identify a segmentation fault, rather than using some difficult method to detect memory leaks or other abnormal behavior.
It is safe to call this function with a NULL pointer. For example:
Slapi_PBlock *pb = NULL;
slapi_pblock_destroy(pb);
This saves the trouble of checking for NULL before calling slapi_pblock_destroy().