mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-06 06:59:54 -05:00
slap_strncopy function
This commit is contained in:
parent
f8fb4aca76
commit
725e13dade
2 changed files with 20 additions and 0 deletions
|
|
@ -229,6 +229,24 @@ slap_strcopy(
|
|||
return a-1;
|
||||
}
|
||||
|
||||
/* strncopy is like strcpy except it returns a pointer to the trailing NUL of
|
||||
* the result string. This allows fast construction of catenated strings
|
||||
* without the overhead of strlen/strcat.
|
||||
*/
|
||||
char *
|
||||
slap_strncopy(
|
||||
char *a,
|
||||
const char *b,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
if (!a || !b || n == 0)
|
||||
return a;
|
||||
|
||||
while ((*a++ = *b++) && n-- > 0) ;
|
||||
return a-1;
|
||||
}
|
||||
|
||||
/* Unlike charray_add, bvarray_add does not make a new copy of the
|
||||
* source string. Typically it is used where ber_bvecadd was before,
|
||||
* and ber_bvecadd didn't duplicate its source either.
|
||||
|
|
|
|||
|
|
@ -283,6 +283,8 @@ LDAP_SLAPD_F (void) bvarray_free LDAP_P(( struct berval *a ));
|
|||
|
||||
LDAP_SLAPD_F (char *) slap_strcopy LDAP_P((
|
||||
char *dst, const char *src ));
|
||||
LDAP_SLAPD_F (char *) slap_strncopy LDAP_P((
|
||||
char *dst, const char *src, size_t n ));
|
||||
|
||||
/*
|
||||
* controls.c
|
||||
|
|
|
|||
Loading…
Reference in a new issue