1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +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:
Brenden Matthews 2008-04-02 19:46:09 +00:00
parent a6a4a4c548
commit 77f8e9bba7
3 changed files with 20 additions and 1 deletions

View File

@ -470,7 +470,7 @@ dnl
dnl Some functions dnl Some functions
dnl 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_SEARCH_LIBS(clock_gettime, [rt],
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])], [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
[AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], []) [AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])

View File

@ -34,6 +34,20 @@
#include <sys/time.h> #include <sys/time.h>
#include <pthread.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) void update_uname(void)
{ {
uname(&info.uname_s); uname(&info.uname_s);

View File

@ -64,6 +64,11 @@
#include <machine/apmvar.h> #include <machine/apmvar.h>
#endif /* __OpenBSD__ */ #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 #ifdef AUDACIOUS
#include "audacious.h" #include "audacious.h"
#endif #endif