diff options
author | Werner Koch <wk@gnupg.org> | 2021-03-25 12:29:31 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2021-03-26 14:30:58 +0100 |
commit | 6a80d6f9206eae2c867c45daa5cd3e7d6c6ad114 (patch) | |
tree | 7e25f41913ce23634fa05db39b0e9b4ba1cb99ef | |
parent | scd: Fix PC/SC error handling at apdu_dev_list_start. (diff) | |
download | gnupg2-6a80d6f9206eae2c867c45daa5cd3e7d6c6ad114.tar.xz gnupg2-6a80d6f9206eae2c867c45daa5cd3e7d6c6ad114.zip |
indent: Modernize mem2str.
--
-rw-r--r-- | common/stringhelp.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/common/stringhelp.c b/common/stringhelp.c index a324bfbbc..24524e805 100644 --- a/common/stringhelp.c +++ b/common/stringhelp.c @@ -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; - - if( n ) { - if( !dest ) - dest = xmalloc( n ) ; - d = dest; - s = src ; - for(n--; n && *s; n-- ) - *d++ = *s++; - *d = '\0' ; + 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' ; } - return dest ; + return dest; } |