Update safe string copy for better debug flow and fix filename typo.
This commit is contained in:
parent
d1b2cb96a6
commit
cd6121019b
|
@ -29,6 +29,9 @@
|
|||
* Will return the length copied (and whether it overflowed or not).
|
||||
*/
|
||||
char *strscpy(char *restrict dest, const char* restrict src, size_t n) {
|
||||
/* Sanity check. */
|
||||
assert(dest && src);
|
||||
|
||||
/* Copy using memcpy. */
|
||||
char *last = memccpy(dest, src, NULL_CHAR, n);
|
||||
|
|
@ -20,6 +20,13 @@
|
|||
#define STRSCPY_H
|
||||
/* Include string.h */
|
||||
#include <string.h>
|
||||
/* Include assert.h to allow code generation, but only run with debug flag. */
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
#define NDEBUG
|
||||
#endif /* NDEBUG. */
|
||||
#endif /* DEBUG. */
|
||||
#include <assert.h>
|
||||
|
||||
/* Constants. */
|
||||
#define NULL_CHAR '\0'
|
||||
|
|
Loading…
Reference in New Issue