indent: Modernize mem2str.

--
This commit is contained in:
Werner Koch 2021-03-25 12:29:31 +01:00
parent d4e5979c63
commit 6a80d6f920
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 19 additions and 17 deletions

View File

@ -160,30 +160,32 @@ ascii_memistr ( const void *buffer, size_t buflen, const char *sub )
return NULL;
}
/* This function is similar to strncpy(). However it won't copy more
than N - 1 characters and makes sure that a '\0' is appended. With
N given as 0, nothing will happen. With DEST given as NULL, memory
will be allocated using xmalloc (i.e. if it runs out of core
the function terminates). Returns DES or a pointer to the
allocated memory.
* than N - 1 characters and makes sure that a '\0' is appended. With
* N given as 0, nothing will happen. With DEST given as NULL, memory
* will be allocated using xmalloc (i.e. if it runs out of core the
* function terminates). Returns DEST or a pointer to the allocated
* memory.
*/
char *
mem2str( char *dest , const void *src , size_t n )
mem2str (char *dest, const void *src, size_t n)
{
char *d;
const char *s;
char *d;
const char *s;
if( n ) {
if( !dest )
dest = xmalloc( n ) ;
d = dest;
s = src ;
for(n--; n && *s; n-- )
*d++ = *s++;
*d = '\0' ;
if (n)
{
if (!dest)
dest = xmalloc (n);
d = dest;
s = src ;
for (n--; n && *s; n--)
*d++ = *s++;
*d = '\0' ;
}
return dest ;
return dest;
}