mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 12:27:52 +00:00
define our own strndup() when its not available (thanks to Pippijn for the idea)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1101 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
a6a4a4c548
commit
77f8e9bba7
@ -470,7 +470,7 @@ dnl
|
||||
dnl Some functions
|
||||
dnl
|
||||
|
||||
AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr])
|
||||
AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr strndup])
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt],
|
||||
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
|
||||
[AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
|
||||
|
14
src/common.c
14
src/common.c
@ -34,6 +34,20 @@
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
// use our own strndup() if it's not available
|
||||
char *strndup(const char *s, size_t n)
|
||||
{
|
||||
if (strlen(s) + 1 > n) {
|
||||
char *ret = malloc(n);
|
||||
strncpy(ret, s, n);
|
||||
return ret;
|
||||
} else {
|
||||
return strdup(s);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
void update_uname(void)
|
||||
{
|
||||
uname(&info.uname_s);
|
||||
|
@ -64,6 +64,11 @@
|
||||
#include <machine/apmvar.h>
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
// use our own strndup() if it's not available
|
||||
char *strndup(const char *s, size_t n);
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user