mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
Add ber_bvstr and ber_bvstrdup string to berval allocators.
This commit is contained in:
parent
ab7c490960
commit
37d28e7d0d
@ -470,6 +470,14 @@ LIBLBER_F( struct berval * )
|
||||
ber_bvdup LDAP_P((
|
||||
LDAP_CONST struct berval *bv ));
|
||||
|
||||
LIBLBER_F( struct berval * )
|
||||
ber_bvstr LDAP_P((
|
||||
LDAP_CONST char * ));
|
||||
|
||||
LIBLBER_F( struct berval * )
|
||||
ber_bvstrdup LDAP_P((
|
||||
LDAP_CONST char * ));
|
||||
|
||||
LIBLBER_F( char * )
|
||||
ber_strdup LDAP_P((
|
||||
LDAP_CONST char * ));
|
||||
|
@ -118,7 +118,7 @@
|
||||
# define LIBLUTIL_F(type) extern type
|
||||
#endif
|
||||
|
||||
/* SLAPD (as a module exporting symbols */
|
||||
/* SLAPD (as a module exporting symbols) */
|
||||
#if defined(LIBSLAPD_DECL) && defined(_WIN32)
|
||||
# define LIBSLAPD_F(type) extern __declspec(LIBSLAPD_DECL) type
|
||||
#else
|
||||
|
@ -292,6 +292,66 @@ ber_bvdup(
|
||||
return( new );
|
||||
}
|
||||
|
||||
struct berval *
|
||||
ber_bvstr(
|
||||
LDAP_CONST char *s )
|
||||
{
|
||||
struct berval *new;
|
||||
|
||||
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
||||
|
||||
if( s == NULL ) {
|
||||
ber_errno = LBER_ERROR_PARAM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) {
|
||||
ber_errno = LBER_ERROR_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( *s == '\0' ) {
|
||||
new->bv_val = NULL;
|
||||
new->bv_len = 0;
|
||||
return new;
|
||||
}
|
||||
|
||||
new->bv_val = (char *) s;
|
||||
new->bv_len = strlen( s );
|
||||
|
||||
return( new );
|
||||
}
|
||||
|
||||
struct berval *
|
||||
ber_bvstrdup(
|
||||
LDAP_CONST char *s )
|
||||
{
|
||||
struct berval *new;
|
||||
char *p;
|
||||
|
||||
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
||||
|
||||
if( s == NULL ) {
|
||||
ber_errno = LBER_ERROR_PARAM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = LBER_STRDUP( s );
|
||||
|
||||
if( p == NULL ) {
|
||||
ber_errno = LBER_ERROR_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = ber_bvstr( p );
|
||||
|
||||
if( new == NULL || *p == '\0' ) {
|
||||
LBER_FREE( p );
|
||||
}
|
||||
|
||||
return( new );
|
||||
}
|
||||
|
||||
char *
|
||||
ber_strdup( LDAP_CONST char *s )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user