diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-11-26 16:44:22 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-11-26 16:44:22 +0100 |
commit | e232712341017f8c6c83b40d8252ad61252c87bc (patch) | |
tree | 729fc6c1c9ea45a3d6e00c1994b363f92142d573 | |
parent | sprintf considered safer (diff) | |
download | slibc-e232712341017f8c6c83b40d8252ad61252c87bc.tar.gz slibc-e232712341017f8c6c83b40d8252ad61252c87bc.tar.bz2 slibc-e232712341017f8c6c83b40d8252ad61252c87bc.tar.xz |
doc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/string/new.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/string/new.c b/src/string/new.c index 56b4e92..01111f7 100644 --- a/src/string/new.c +++ b/src/string/new.c @@ -146,7 +146,22 @@ char* (strnchrnul)(const char* string, int c, size_t maxlen) return string; } -char* (memcchr)(const char* segment, int c, int stop, size_t size) /* slibc: completeness */ +/** + * Variant of `memchr` that stops searching when it + * another specified character. + * + * This is a slibc extension added for completeness. + * + * @param segment The memory segment to search. + * @param c The sought after character. + * @param stop Return `NULL` when this character is found. + * @param size The size of the memory segment. + * @return Pointer to the first occurrence of `c`, + * `NULL` if none were found. + * + * @since Always. + */ +char* (memcchr)(const char* segment, int c, int stop, size_t size) { char* s = segment; for (;;) @@ -156,7 +171,23 @@ char* (memcchr)(const char* segment, int c, int stop, size_t size) /* slibc: com return NULL; } -char* (strcchr)(const char* string, int c, int stop) /* slibc: completeness */ +/** + * Variant of `strchr` that stops searching when it + * another specified character. + * + * This is a slibc extension added for completeness. + * + * @param string The string to search. + * The terminating NUL character is + * considered a part of the string. + * @param c The sought after character. + * @param stop Return `NULL` when this character is found. + * @return Pointer to the first occurrence of `c`, + * `NULL` if none were found. + * + * @since Always. + */ +char* (strcchr)(const char* string, int c, int stop) { for (;;) if (*string == c) @@ -165,7 +196,24 @@ char* (strcchr)(const char* string, int c, int stop) /* slibc: completeness */ return NULL; } -char* (strcnchr)(const char* string, int c, int stop, size_t maxlen) /* slibc: completeness */ +/** + * Variant of `strnchr` that stops searching when it + * another specified character. + * + * This is a slibc extension added for completeness. + * + * @param string The string to search. + * The terminating NUL character is + * considered a part of the string. + * @param c The sought after character. + * @param stop Return `NULL` when this character is found. + * @param maxlen The number of bytes to inspect, at most. + * @return Pointer to the first occurrence of `c`, + * `NULL` if none were found. + * + * @since Always. + */ +char* (strcnchr)(const char* string, int c, int stop, size_t maxlen) { for (;;) if (*string == c) |