diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-25 11:11:35 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-28 11:39:03 -0700 |
| commit | 601c64ec4f2b8a41fba59d31a987090feeb69e84 (patch) | |
| tree | 985ec57b3e238b4eed9b42ddaa4736b949df8c6f /src/core/strs.h | |
| parent | 595da8102f3e34e95dad351bc55cd45421616723 (diff) | |
| download | nng-601c64ec4f2b8a41fba59d31a987090feeb69e84.tar.gz nng-601c64ec4f2b8a41fba59d31a987090feeb69e84.tar.bz2 nng-601c64ec4f2b8a41fba59d31a987090feeb69e84.zip | |
Introduce utility safe string handling functions.
We have our versions of strdup, strlcat, and strlcpy.
This means we can avoid using snprintf() in many cases
(saving cycles), and we can get safer checks. We use
the platform supplied versions of these if they exist
(wrapping with nni_xxx versions.)
Diffstat (limited to 'src/core/strs.h')
| -rw-r--r-- | src/core/strs.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/strs.h b/src/core/strs.h new file mode 100644 index 00000000..741504cd --- /dev/null +++ b/src/core/strs.h @@ -0,0 +1,21 @@ +// +// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#ifndef CORE_STRS_H +#define CORE_STRS_H + +// Safe string functions, in case the platform misses these. + +extern char * nni_strdup(const char *); +extern void nni_strfree(char *); +extern size_t nni_strlcpy(char *, const char *, size_t); +extern size_t nni_strlcat(char *, const char *, size_t); + +#endif // CORE_STRS_H |
