mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
New DS 5.x memory management API memory management API memory management API memory management API
This commit is contained in:
parent
293c765c11
commit
2107a4c1b3
@ -431,6 +431,65 @@ slapi_ch_free_string( char **ptr )
|
|||||||
#endif /* defined(LDAP_SLAPI) */
|
#endif /* defined(LDAP_SLAPI) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
slapi_ch_array_free( char **arrayp )
|
||||||
|
{
|
||||||
|
#ifdef LDAP_SLAPI
|
||||||
|
char **p;
|
||||||
|
|
||||||
|
if ( arrayp != NULL ) {
|
||||||
|
for ( p = arrayp; *p != NULL; p++ ) {
|
||||||
|
slapi_ch_free( (void **)p );
|
||||||
|
}
|
||||||
|
slapi_ch_free( (void **)&arrayp );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
struct berval *
|
||||||
|
slapi_ch_bvdup(const struct berval *v)
|
||||||
|
{
|
||||||
|
#ifdef LDAP_SLAPI
|
||||||
|
struct berval *bv;
|
||||||
|
|
||||||
|
bv = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
|
||||||
|
bv->bv_len = v->bv_len;
|
||||||
|
bv->bv_val = slapi_ch_malloc( bv->bv_len );
|
||||||
|
AC_MEMCPY( bv->bv_val, v->bv_val, bv->bv_len );
|
||||||
|
|
||||||
|
return bv;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
struct berval **
|
||||||
|
slapi_ch_bvecdup(const struct berval **v)
|
||||||
|
{
|
||||||
|
#ifdef LDAP_SLAPI
|
||||||
|
int i;
|
||||||
|
struct berval **rv;
|
||||||
|
|
||||||
|
if ( v == NULL ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; v[i] != NULL; i++ )
|
||||||
|
;
|
||||||
|
|
||||||
|
rv = (struct berval **) slapi_ch_malloc( (i + 1) * sizeof(struct berval *) );
|
||||||
|
|
||||||
|
for ( i = 0; v[i] != NULL; i++ ) {
|
||||||
|
rv[i] = slapi_ch_bvdup( v[i] );
|
||||||
|
}
|
||||||
|
rv[i] = NULL;
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
slapi_ch_calloc(
|
slapi_ch_calloc(
|
||||||
unsigned long nelem,
|
unsigned long nelem,
|
||||||
|
@ -134,6 +134,10 @@ void slapi_ch_free_string( char **s );
|
|||||||
char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
|
char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
|
||||||
char *slapi_ch_realloc( char *block, unsigned long size );
|
char *slapi_ch_realloc( char *block, unsigned long size );
|
||||||
char *slapi_ch_strdup( char *s );
|
char *slapi_ch_strdup( char *s );
|
||||||
|
void slapi_ch_array_free( char **arrayp );
|
||||||
|
struct berval *slapi_ch_bvdup(const struct berval *v);
|
||||||
|
struct berval **slapi_ch_bvecdup(const struct berval **v);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: these two were missing, but widely used in a couple of .c files
|
* FIXME: these two were missing, but widely used in a couple of .c files
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user