share/mk/: Remove unused variable
[man-pages.git] / man3 / memmem.3
bloba807412b0135035b50d7bd9f5b2febe35fb66dc9
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\"     Linux libc source code
8 .\"     386BSD man pages
9 .\" Modified Sat Jul 24 18:50:48 1993 by Rik Faith (faith@cs.unc.edu)
10 .\" Interchanged 'needle' and 'haystack'; added history, aeb, 980113.
11 .TH memmem 3 (date) "Linux man-pages (unreleased)"
12 .SH NAME
13 memmem \- locate a substring
14 .SH LIBRARY
15 Standard C library
16 .RI ( libc ", " \-lc )
17 .SH SYNOPSIS
18 .nf
19 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
20 .B #include <string.h>
22 .BI "void *memmem(const void " haystack [. haystacklen "], size_t " haystacklen ,
23 .BI "             const void " needle [. needlelen "], size_t " needlelen  );
24 .fi
25 .SH DESCRIPTION
26 The
27 .BR memmem ()
28 function finds the start of the first occurrence
29 of the substring
30 .I needle
31 of length
32 .I needlelen
33 in the memory
34 area
35 .I haystack
36 of length
37 .IR haystacklen .
38 .SH RETURN VALUE
39 The
40 .BR memmem ()
41 function returns a pointer to the beginning of the
42 substring, or NULL if the substring is not found.
43 .SH ATTRIBUTES
44 For an explanation of the terms used in this section, see
45 .BR attributes (7).
46 .TS
47 allbox;
48 lbx lb lb
49 l l l.
50 Interface       Attribute       Value
52 .na
53 .nh
54 .BR memmem ()
55 T}      Thread safety   MT-Safe
56 .TE
57 .SH STANDARDS
58 None.
59 .SH HISTORY
60 musl libc 0.9.7;
61 FreeBSD 6.0, OpenBSD 5.4, NetBSD, Illumos.
62 .SH BUGS
63 .\" This function was broken in Linux libraries up to and including libc 5.0.9;
64 .\" there the
65 .\" .IR needle
66 .\" and
67 .\" .I haystack
68 .\" arguments were interchanged,
69 .\" and a pointer to the end of the first occurrence of
70 .\" .I needle
71 .\" was returned.
72 .\"
73 .\" Both old and new libc's have the bug that if
74 .\" .I needle
75 .\" is empty,
76 .\" .I haystack\-1
77 .\" (instead of
78 .\" .IR haystack )
79 .\" is returned.
80 In glibc 2.0, if
81 .I needle
82 is empty,
83 .BR memmem ()
84 returns a pointer to the last byte of
85 .IR haystack .
86 This is fixed in glibc 2.1.
87 .SH SEE ALSO
88 .BR bstring (3),
89 .BR strstr (3)