From: fredrik Date: Mon, 4 Jun 2007 21:59:04 +0000 (+0000) Subject: Make swcsdup not evalulate its argument twice. X-Git-Tag: 0.4~14 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=4344b8c8987cb5627f9ada36ae7a6e19d95ada33;p=doldaconnect.git Make swcsdup not evalulate its argument twice. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1064 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/include/utils.h b/include/utils.h index a1176a6..8cb40dd 100644 --- a/include/utils.h +++ b/include/utils.h @@ -37,7 +37,7 @@ struct wcspair { #define LOGOOM(size) flog(LOG_CRIT, "%s (%s:%i): out of memory (alloc %zi)", __FUNCTION__, __FILE__, __LINE__, (size)) #define smalloc(size) ({void *__result__; ((__result__ = malloc(size)) == NULL)?({LOGOOM((ssize_t)(size)); abort(); (void *)0;}):__result__;}) #define srealloc(ptr, size) ({void *__result__; ((__result__ = realloc((ptr), (size))) == NULL)?({LOGOOM((ssize_t)(size)); abort(); (void *)0;}):__result__;}) -#define swcsdup(wcs) ((wchar_t *)wcscpy(smalloc(sizeof(wchar_t) * (wcslen(wcs) + 1)), (wcs))) +#define swcsdup(wcs) ({wchar_t *__eval__; __eval__ = (wcs); (wchar_t *)wcscpy(smalloc(sizeof(wchar_t) * (wcslen(__eval__) + 1)), __eval__);}) #define sstrdup(str) ((char *)strcpy(smalloc(strlen(str) + 1), (str))) #else #define LOGOOM(size)