mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
indent: Modernize mem2str.
--
This commit is contained in:
parent
d4e5979c63
commit
6a80d6f920
@ -160,30 +160,32 @@ ascii_memistr ( const void *buffer, size_t buflen, const char *sub )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function is similar to strncpy(). However it won't copy more
|
/* 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
|
* 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
|
* 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
|
* will be allocated using xmalloc (i.e. if it runs out of core the
|
||||||
the function terminates). Returns DES or a pointer to the
|
* function terminates). Returns DEST or a pointer to the allocated
|
||||||
allocated memory.
|
* memory.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
mem2str( char *dest , const void *src , size_t n )
|
mem2str (char *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
if( n ) {
|
if (n)
|
||||||
if( !dest )
|
{
|
||||||
dest = xmalloc( n ) ;
|
if (!dest)
|
||||||
d = dest;
|
dest = xmalloc (n);
|
||||||
s = src ;
|
d = dest;
|
||||||
for(n--; n && *s; n-- )
|
s = src ;
|
||||||
*d++ = *s++;
|
for (n--; n && *s; n--)
|
||||||
*d = '\0' ;
|
*d++ = *s++;
|
||||||
|
*d = '\0' ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest ;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user