mirror of https://github.com/BOINC/boinc.git
- eliminate use of alloca() and strdupa().
- don't include malloc.h - fix compile warnings
This commit is contained in:
parent
7735ee4410
commit
13f1257355
|
@ -7907,3 +7907,17 @@ Charlie 26 Dec 2012
|
|||
BOINCInternetFSHandler.cpp,.h
|
||||
NoticeListCtrl.cpp
|
||||
sg_DlgMessages.cpp,.h
|
||||
|
||||
David 27 Dec 2012
|
||||
- eliminate use of alloca() and strdupa().
|
||||
- don't include malloc.h
|
||||
- fix compile warnings
|
||||
|
||||
configure.ac
|
||||
clientscr/
|
||||
screensaver_x11.cpp
|
||||
lib/
|
||||
str_util.cpp
|
||||
sched/
|
||||
hr_info.cpp
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// To use this screensaver, please add the following to the 'programs'
|
||||
// preference in your .xscreensaver file:
|
||||
//
|
||||
// GL: boincscr -root \n\
|
||||
// GL: "boincscr -root \n\"
|
||||
//
|
||||
// If your BOINC directory differs from /var/lib/boinc-client, you can use
|
||||
// the -boinc_dir command line argument.
|
||||
|
@ -169,10 +169,9 @@ public:
|
|||
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||
values[0] = scr->black_pixel;
|
||||
values[1] = XCB_EVENT_MASK_EXPOSURE;
|
||||
xcb_void_cookie_t cookie =
|
||||
xcb_change_window_attributes(con, win, mask, values);
|
||||
cookie = xcb_change_window_attributes(con, win, mask, values);
|
||||
|
||||
xcb_generic_error_t *error = xcb_request_check(con, cookie);
|
||||
error = xcb_request_check(con, cookie);
|
||||
if(error) {
|
||||
std::cerr << "Could not configure window." << std::endl;
|
||||
exit(1);
|
||||
|
@ -419,7 +418,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// get default screen
|
||||
xcb_screen_t *screen;
|
||||
xcb_screen_t *screen = NULL;
|
||||
for(xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(con));
|
||||
it.rem; screen_num--, xcb_screen_next(&it))
|
||||
if(!screen_num) screen = it.data;
|
||||
|
@ -515,7 +514,7 @@ int main(int argc, char *argv[]) {
|
|||
static_cast<xcb_window_t*>(xcb_get_property_value(reply));
|
||||
|
||||
// check if one of them is our graphics app
|
||||
for(int c = 0; c < reply->length; c++) {
|
||||
for(unsigned int c = 0; c < reply->length; c++) {
|
||||
xcb_get_property_reply_t *reply2;
|
||||
|
||||
// check WM_COMMAND
|
||||
|
|
|
@ -611,7 +611,7 @@ AC_HEADER_STDC
|
|||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_TIME
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_HEADERS(windows.h sys/types.h sys/un.h arpa/inet.h dirent.h grp.h fcntl.h inttypes.h stdint.h malloc.h alloca.h memory.h netdb.h netinet/in.h netinet/tcp.h netinet/ether.h signal.h strings.h sys/auxv.h sys/file.h sys/fcntl.h sys/ipc.h sys/ioctl.h sys/msg.h sys/param.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/socket.h sys/stat.h sys/statvfs.h sys/statfs.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h procfs.h ieeefp.h setjmp.h)
|
||||
AC_CHECK_HEADERS(windows.h sys/types.h sys/un.h arpa/inet.h dirent.h grp.h fcntl.h inttypes.h stdint.h memory.h netdb.h netinet/in.h netinet/tcp.h netinet/ether.h signal.h strings.h sys/auxv.h sys/file.h sys/fcntl.h sys/ipc.h sys/ioctl.h sys/msg.h sys/param.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/socket.h sys/stat.h sys/statvfs.h sys/statfs.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h procfs.h ieeefp.h setjmp.h)
|
||||
|
||||
AC_CHECK_HEADER(net/if.h, [], [], [[
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
|
@ -703,11 +703,7 @@ AC_LANG_POP
|
|||
dnl Checks for library functions.
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_FUNC_ALLOCA
|
||||
if test "${ac_cv_func_alloca_works}" = "yes" ; then
|
||||
ac_cv_func_alloca="yes"
|
||||
fi
|
||||
AC_CHECK_FUNCS(alloca _alloca __builtin_alloca ether_ntoa setpriority sched_setscheduler strlcpy strlcat strcasestr strcasecmp sigaction getutent setutent getisax strdup strdupa daemon stat64 putenv setenv unsetenv res_init strtoull)
|
||||
AC_CHECK_FUNCS(ether_ntoa setpriority sched_setscheduler strlcpy strlcat strcasestr strcasecmp sigaction getutent setutent getisax strdup strdupa daemon stat64 putenv setenv unsetenv res_init strtoull)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#if HAVE_ALLOCA_H
|
||||
#include "alloca.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _USING_FCGI_
|
||||
|
@ -83,56 +80,29 @@ size_t strlcat(char *dst, const char *src, size_t size) {
|
|||
#endif // !HAVE_STRLCAT
|
||||
|
||||
#if !HAVE_STRCASESTR
|
||||
// BOINC only uses strcasestr() for short strings,
|
||||
// so the following till suffice
|
||||
//
|
||||
const char *strcasestr(const char *s1, const char *s2) {
|
||||
char *needle=NULL, *haystack=NULL, *p=NULL;
|
||||
bool need_free = false;
|
||||
// Is alloca() really less likely to fail with out of memory error
|
||||
// than strdup?
|
||||
#if HAVE_STRDUPA
|
||||
haystack=strdupa(s1);
|
||||
needle=strdupa(s2);
|
||||
#elif HAVE_ALLOCA_H || HAVE_ALLOCA
|
||||
haystack=(char *)alloca(strlen(s1)+1);
|
||||
needle=(char *)alloca(strlen(s2)+1);
|
||||
if (needle && haystack) {
|
||||
strlcpy(haystack,s1,strlen(s1)+1);
|
||||
strlcpy(needle,s2,strlen(s2)+1);
|
||||
char needle[1024], haystack[1024], *p=NULL;
|
||||
strlcpy(haystack, s1, sizeof(haystack));
|
||||
strlcpy(needle, s2, sizeof(needle));
|
||||
// convert both strings to lower case
|
||||
p = haystack;
|
||||
while (*p) {
|
||||
*p = tolower(*p);
|
||||
p++;
|
||||
}
|
||||
#elif HAVE_STRDUP
|
||||
haystack=strdup(s1);
|
||||
needle=strdup(s1)
|
||||
need_free = true;
|
||||
#else
|
||||
haystack=(char *)malloc(strlen(s1)+1);
|
||||
needle=(char *)malloc(strlen(s2)+1);
|
||||
if (needle && haystack) {
|
||||
strlcpy(haystack,s1,strlen(s1)+1);
|
||||
strlcpy(needle,s2,strlen(s2)+1);
|
||||
p = needle;
|
||||
while (*p) {
|
||||
*p = tolower(*p);
|
||||
p++;
|
||||
}
|
||||
need_free = true;
|
||||
#endif
|
||||
if (needle && haystack) {
|
||||
// convert both strings to lower case
|
||||
p = haystack;
|
||||
while (*p) {
|
||||
*p = tolower(*p);
|
||||
p++;
|
||||
}
|
||||
p = needle;
|
||||
while (*p) {
|
||||
*p = tolower(*p);
|
||||
p++;
|
||||
}
|
||||
// find the substring
|
||||
p = strstr(haystack, needle);
|
||||
// correct the pointer to point to the substring within s1
|
||||
if (p) {
|
||||
p = const_cast<char *>(s1)+(p-haystack);
|
||||
}
|
||||
}
|
||||
if (need_free) {
|
||||
if (needle) free(needle);
|
||||
if (haystack) free(haystack);
|
||||
// find the substring
|
||||
p = strstr(haystack, needle);
|
||||
// correct the pointer to point to the substring within s1
|
||||
if (p) {
|
||||
p = const_cast<char *>(s1)+(p-haystack);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#else
|
||||
#include "boinc_fcgi.h"
|
||||
#endif
|
||||
#if HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <cmath>
|
||||
|
||||
#include "error_numbers.h"
|
||||
|
|
Loading…
Reference in New Issue