diff options
author | Austin Clements <amdragon@MIT.EDU> | 2014-07-31 22:09:52 -0400 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-08-06 09:56:36 -0300 |
commit | 9f0f30f7dea1b8fd888d774175ed96d802118b11 (patch) | |
tree | 71f92e78bf3ca5ee579c503a83cb103b7386cefa /util/string-util.h | |
parent | c95a398debc99ecc43d451e34d85c97e57c39b42 (diff) |
util: Const version of strtok_len
Because of limitations in the C type system, we can't a strtok_len
that can work on both const string and non-const strings. The C
library solves this by taking a const char* and returning a char*
in functions like this (e.g., strchr), but that's not const-safe.
Solve it by introducing strtok_len_c, a version of strtok_len for
const strings.
Diffstat (limited to 'util/string-util.h')
-rw-r--r-- | util/string-util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/util/string-util.h b/util/string-util.h index ccad17f1..e409cb3d 100644 --- a/util/string-util.h +++ b/util/string-util.h @@ -23,6 +23,9 @@ extern "C" { char *strtok_len (char *s, const char *delim, size_t *len); +/* Const version of strtok_len. */ +const char *strtok_len_c (const char *s, const char *delim, size_t *len); + /* Return a talloced string with str sanitized. * * Whitespace characters (tabs and newlines) are replaced with spaces, |