Netscape DIRECTORY SERVER 6.2 - PLUG-IN Manual page 423

Table of Contents

Advertisement

Functions for Managing Parameter Block
int connid = 0;
...
retval = slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
is an integer value, so you will pass in a pointer to/address of an
SLAPI_CONN_ID
integer to get the value. Similarly, for a char
(a string), pass in a pointer
* value
to/address of the value. For example:
char *binddn = NULL;
...
retval = slapi_pblock_get(pb, SLAPI_CONN_DN, &binddn);
With certain compilers on some platforms, you may have to cast the value to
(void
.
*)
We recommend that you set the value to
or
before calling
0
NULL
to avoid reading from uninitialized memory, in case the call
slapi_pblock_get()
to
fails.
slapi_pblock_get()
In most instances, the caller should not free the returned value. The value will
usually be freed internally or through the call to
. The
slapi_pblock_destroy()
exception is if the value is explicitly set by the caller through
.
slapi_pblock_set()
In this case, the caller is responsible for memory management. If the value is freed,
it is strongly recommended that the free is followed by a call to
with a value of
. For example:
slapi_pblock_set()
NULL
char *someparam = NULL;
...
someparam = slapi_ch_strdup(somestring);
slapi_pblock_set(pb, SOME_PARAM, someparam);
someparam = NULL; /* avoid dangling reference */
...
slapi_pblock_get(pb, SOME_PARAM, &someparam);
slapi_pblock_set(pb, SOME_PARAM, NULL); /* make sure no one else can
reference this parameter */
slapi_ch_free_string(&someparam);
...
Some internal functions may change the value passed in, so it is recommended to
use
to retrieve the value again, rather than relying on a
slapi_pblock_get()
potential dangling pointer. This is shown in the example above, which sets
to
after setting it in the
.
someparam
NULL
pblock
Chapter 15
Function Reference
423

Advertisement

Table of Contents
loading

This manual is also suitable for:

Directory server 6.2

Table of Contents