Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
81557849
Commit
81557849
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string_util: add fallback for strnlen()
Usually, when strndup() is not available, strndup() isn't either, because both are POSIX 2008.
parent
44725e48
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
configure.ac
configure.ac
+1
-1
string_util.c
src/string_util.c
+15
-0
string_util.h
src/string_util.h
+8
-0
No files found.
configure.ac
View file @
81557849
...
...
@@ -136,7 +136,7 @@ AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_CHECK_FUNCS(pipe2 accept4 eventfd)
AC_CHECK_FUNCS(strndup)
AC_CHECK_FUNCS(strn
len strn
dup)
AC_SEARCH_LIBS([exp], [m],,
[AC_MSG_ERROR([exp() not found])])
...
...
src/string_util.c
View file @
81557849
...
...
@@ -48,6 +48,21 @@ string_array_contains(const char *const* haystack, const char *needle)
return
false
;
}
#ifndef HAVE_STRNLEN
size_t
strnlen
(
const
char
*
s
,
size_t
max
)
{
assert
(
s
!=
NULL
);
const
char
*
t
=
memchr
(
s
,
0
,
max
);
return
t
!=
NULL
?
(
size_t
)(
t
-
s
)
:
max
;
}
#endif
#if !defined(HAVE_STRNDUP)
char
*
...
...
src/string_util.h
View file @
81557849
...
...
@@ -83,6 +83,14 @@ strchug_fast(char *p)
bool
string_array_contains
(
const
char
*
const
*
haystack
,
const
char
*
needle
);
#ifndef HAVE_STRNLEN
gcc_pure
size_t
strnlen
(
const
char
*
s
,
size_t
max
);
#endif
#if !defined(HAVE_STRNDUP)
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment