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
023b9c1e
Commit
023b9c1e
authored
Jan 26, 2015
by
PHO
Committed by
Max Kellermann
Jan 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the existence of strndup(3) before using it.
This can eliminate the ad-hoc "#ifdef WIN32" and can also support other platforms lacking it as well (including Darwin 9).
parent
4c616626
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
NEWS
NEWS
+1
-0
configure.ac
configure.ac
+1
-0
Alloc.cxx
src/util/Alloc.cxx
+6
-5
No files found.
NEWS
View file @
023b9c1e
ver 0.19.9 (not yet released)
* fix build failure with uClibc
* fix build failure on non-POSIX operating systems
ver 0.19.8 (2015/01/14)
* input
...
...
configure.ac
View file @
023b9c1e
...
...
@@ -206,6 +206,7 @@ if test x$host_is_linux = xyes; then
fi
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
AC_CHECK_FUNCS(strndup)
if test x$host_is_linux = xyes; then
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
...
...
src/util/Alloc.cxx
View file @
023b9c1e
...
...
@@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Alloc.hxx"
#include <stdlib.h>
...
...
@@ -62,14 +63,14 @@ xstrdup(const char *s)
char
*
xstrndup
(
const
char
*
s
,
size_t
n
)
{
#ifdef WIN32
char
*
p
=
(
char
*
)
xalloc
(
n
+
1
);
memcpy
(
p
,
s
,
n
);
p
[
n
]
=
0
;
#else
#ifdef HAVE_STRNDUP
char
*
p
=
strndup
(
s
,
n
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
#else
char
*
p
=
(
char
*
)
xalloc
(
n
+
1
);
memcpy
(
p
,
s
,
n
);
p
[
n
]
=
0
;
#endif
return
p
;
...
...
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