diff options
| author | Alejandro Colomar <alx@kernel.org> | 2023-01-05 20:01:02 +0100 |
|---|---|---|
| committer | Alejandro Colomar <alx@kernel.org> | 2023-01-05 20:01:06 +0100 |
| commit | b2af20ea4408faa66564d2d742f0e22b02017510 (patch) | |
| tree | b8d596f7394b7d7b0ebbed1f97f72d1b57cb8ddf | |
| parent | 588a1a5f85d210c5c258e04b6bad99f108b0149a (diff) | |
| download | man-pages-b2af20ea4408faa66564d2d742f0e22b02017510.tar.gz | |
memchr.3: Deprecate rawmemchr(3)
It is not optimized, and it calls either strlen(3) or memchr(3), so the
caller can do it directly, and it will be better.
Suggested-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
| -rw-r--r-- | man3/memchr.3 | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/man3/memchr.3 b/man3/memchr.3 index 68873964e5..e03001bec0 100644 --- a/man3/memchr.3 +++ b/man3/memchr.3 @@ -22,7 +22,8 @@ Standard C library .PP .BI "void *memchr(const void " s [. n "], int " c ", size_t " n ); .BI "void *memrchr(const void " s [. n "], int " c ", size_t " n ); -.BI "void *rawmemchr(const void " s [. n "], int " c ); +.PP +.BI "[[deprecated]] void *rawmemchr(const void " s [. n "], int " c ); .fi .PP .RS -4 @@ -66,26 +67,21 @@ instead of forward from the beginning. The .BR rawmemchr () function is similar to -.BR memchr (): -it assumes (i.e., the programmer knows for certain) +.BR memchr (), +but it assumes +(i.e., the programmer knows for certain) that an instance of .I c lies somewhere in the memory area starting at the location pointed to by -.IR s , -and so performs an optimized search for -.I c -(i.e., no use of a count argument to limit the range of the search). +.IR s . If an instance of .I c -is not found, the results are unpredictable. -The following call is a fast means of locating a string's -terminating null byte: -.PP -.in +4n -.EX -char *p = rawmemchr(s,\ \(aq\e0\(aq); -.EE -.in +is not found, the behavior is undefined. +Use either +.BR strlen (3) +or +.BR memchr (3) +instead. .SH RETURN VALUE The .BR memchr () |
