xwin: use calloc() instead of malloc()
Using calloc() instead of malloc() as preventive measure, so there never can be any hidden bugs or leaks due uninitialized memory. The extra cost of using this compiler intrinsic should be practically impossible to measure - in many cases a good compiler can even deduce if certain areas really don't need to be zero'd (because they're written to right after allocation) and create more efficient machine code. The code pathes in question are pretty cold anyways, so it's probably not worth even thinking about potential extra runtime costs. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
8f26a2f6a7
commit
5377ee4d81
|
@ -463,7 +463,7 @@ winFixupPaths(void)
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
if (fontpath == NULL)
|
if (fontpath == NULL)
|
||||||
fontpath = malloc(newsize + 1);
|
fontpath = calloc(1, newsize + 1);
|
||||||
else
|
else
|
||||||
fontpath = realloc(fontpath, newsize + 1);
|
fontpath = realloc(fontpath, newsize + 1);
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ winFixupPaths(void)
|
||||||
while (ptr != NULL) {
|
while (ptr != NULL) {
|
||||||
size_t oldfp_len = (ptr - oldptr);
|
size_t oldfp_len = (ptr - oldptr);
|
||||||
size_t newsize = oldfp_len;
|
size_t newsize = oldfp_len;
|
||||||
char *newpath = malloc(newsize + 1);
|
char *newpath = calloc(1, newsize + 1);
|
||||||
|
|
||||||
strncpy(newpath, oldptr, newsize);
|
strncpy(newpath, oldptr, newsize);
|
||||||
newpath[newsize] = 0;
|
newpath[newsize] = 0;
|
||||||
|
@ -518,7 +518,7 @@ winFixupPaths(void)
|
||||||
char *compose;
|
char *compose;
|
||||||
|
|
||||||
newsize = newsize - libx11dir_len + basedirlen;
|
newsize = newsize - libx11dir_len + basedirlen;
|
||||||
compose = malloc(newsize + 1);
|
compose = calloc(1, newsize + 1);
|
||||||
strcpy(compose, basedir);
|
strcpy(compose, basedir);
|
||||||
strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
|
strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
|
||||||
compose[newsize] = 0;
|
compose[newsize] = 0;
|
||||||
|
@ -532,7 +532,7 @@ winFixupPaths(void)
|
||||||
newfp_len += newsize;
|
newfp_len += newsize;
|
||||||
|
|
||||||
if (newfp == NULL)
|
if (newfp == NULL)
|
||||||
newfp = malloc(newfp_len + 1);
|
newfp = calloc(1, newfp_len + 1);
|
||||||
else
|
else
|
||||||
newfp = realloc(newfp, newfp_len + 1);
|
newfp = realloc(newfp, newfp_len + 1);
|
||||||
|
|
||||||
|
|
|
@ -843,9 +843,7 @@ glxWinCreateDrawable(ClientPtr client,
|
||||||
DrawablePtr pDraw,
|
DrawablePtr pDraw,
|
||||||
XID drawId, int type, XID glxDrawId, __GLXconfig * conf)
|
XID drawId, int type, XID glxDrawId, __GLXconfig * conf)
|
||||||
{
|
{
|
||||||
__GLXWinDrawable *glxPriv;
|
__GLXWinDrawable *glxPriv = calloc(1, sizeof *glxPriv);
|
||||||
|
|
||||||
glxPriv = malloc(sizeof *glxPriv);
|
|
||||||
|
|
||||||
if (glxPriv == NULL)
|
if (glxPriv == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1969,7 +1967,7 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
// allocate and save
|
// allocate and save
|
||||||
work = malloc(sizeof(GLXWinConfig));
|
work = calloc(1, sizeof(GLXWinConfig));
|
||||||
if (NULL == work) {
|
if (NULL == work) {
|
||||||
ErrorF("Failed to allocate GLXWinConfig\n");
|
ErrorF("Failed to allocate GLXWinConfig\n");
|
||||||
break;
|
break;
|
||||||
|
@ -2383,7 +2381,7 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats *
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
// allocate and save
|
// allocate and save
|
||||||
work = malloc(sizeof(GLXWinConfig));
|
work = calloc(1, sizeof(GLXWinConfig));
|
||||||
if (NULL == work) {
|
if (NULL == work) {
|
||||||
ErrorF("Failed to allocate GLXWinConfig\n");
|
ErrorF("Failed to allocate GLXWinConfig\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -81,10 +81,6 @@ GenerateAuthorization(unsigned name_length,
|
||||||
BOOL
|
BOOL
|
||||||
winGenerateAuthorization(void)
|
winGenerateAuthorization(void)
|
||||||
{
|
{
|
||||||
#ifdef XCSECURITY
|
|
||||||
SecurityAuthorizationPtr pAuth = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Call OS layer to generate authorization key */
|
/* Call OS layer to generate authorization key */
|
||||||
g_authId = GenerateAuthorization(strlen(AUTH_NAME),
|
g_authId = GenerateAuthorization(strlen(AUTH_NAME),
|
||||||
AUTH_NAME,
|
AUTH_NAME,
|
||||||
|
@ -107,8 +103,7 @@ winGenerateAuthorization(void)
|
||||||
|
|
||||||
#ifdef XCSECURITY
|
#ifdef XCSECURITY
|
||||||
/* Allocate structure for additional auth information */
|
/* Allocate structure for additional auth information */
|
||||||
pAuth = (SecurityAuthorizationPtr)
|
SecurityAuthorizationPtr pAuth = calloc(1, sizeof(SecurityAuthorizationRec));
|
||||||
malloc(sizeof(SecurityAuthorizationRec));
|
|
||||||
if (!(pAuth)) {
|
if (!(pAuth)) {
|
||||||
ErrorF("winGenerateAuthorization - Failed allocating "
|
ErrorF("winGenerateAuthorization - Failed allocating "
|
||||||
"SecurityAuthorizationPtr.\n");
|
"SecurityAuthorizationPtr.\n");
|
||||||
|
|
|
@ -100,7 +100,7 @@ winClipboardUNIXtoDOS(char **ppszData, int iLength)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Allocate a new string */
|
/* Allocate a new string */
|
||||||
pszDestBegin = pszDest = malloc(iLength + iNewlineCount + 1);
|
pszDestBegin = pszDest = calloc(1, iLength + iNewlineCount + 1);
|
||||||
|
|
||||||
/* Set source pointer to beginning of data string */
|
/* Set source pointer to beginning of data string */
|
||||||
pszSrc = *ppszData;
|
pszSrc = *ppszData;
|
||||||
|
|
|
@ -138,7 +138,7 @@ static char *get_atom_name(xcb_connection_t *conn, xcb_atom_t atom)
|
||||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(conn, cookie, NULL);
|
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(conn, cookie, NULL);
|
||||||
if (!reply)
|
if (!reply)
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = malloc(xcb_get_atom_name_name_length(reply) + 1);
|
ret = calloc(1, xcb_get_atom_name_name_length(reply) + 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
memcpy(ret, xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
memcpy(ret, xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||||
ret[xcb_get_atom_name_name_length(reply)] = '\0';
|
ret[xcb_get_atom_name_name_length(reply)] = '\0';
|
||||||
|
@ -166,7 +166,7 @@ winClipboardSelectionNotifyTargets(HWND hwnd, xcb_window_t iWindow, xcb_connecti
|
||||||
xcb_atom_t *prop = xcb_get_property_value(reply);
|
xcb_atom_t *prop = xcb_get_property_value(reply);
|
||||||
int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t);
|
int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t);
|
||||||
int i;
|
int i;
|
||||||
data->targetList = malloc((nitems+1)*sizeof(xcb_atom_t));
|
data->targetList = calloc(nitems+1, sizeof(xcb_atom_t));
|
||||||
|
|
||||||
for (i = 0; i < nitems; i++)
|
for (i = 0; i < nitems; i++)
|
||||||
{
|
{
|
||||||
|
@ -242,8 +242,8 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
||||||
if (encoding == atoms->atomIncr) {
|
if (encoding == atoms->atomIncr) {
|
||||||
winDebug("winClipboardSelectionNotifyData: starting INCR, anticipated size %d\n", *(int *)value);
|
winDebug("winClipboardSelectionNotifyData: starting INCR, anticipated size %d\n", *(int *)value);
|
||||||
data->incrsize = 0;
|
data->incrsize = 0;
|
||||||
data->incr = malloc(*(int *)value);
|
data->incr = calloc(1, *(int *)value);
|
||||||
// XXX: if malloc failed, we have an error
|
// XXX: if calloc failed, we have an error
|
||||||
return WIN_XEVENTS_SUCCESS;
|
return WIN_XEVENTS_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (data->incr) {
|
else if (data->incr) {
|
||||||
|
@ -276,23 +276,23 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xtpText_encoding == atoms->atomUTF8String) {
|
if (xtpText_encoding == atoms->atomUTF8String) {
|
||||||
pszReturnData = malloc(xtpText_nitems + 1);
|
pszReturnData = calloc(1, xtpText_nitems + 1);
|
||||||
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
||||||
pszReturnData[xtpText_nitems] = 0;
|
pszReturnData[xtpText_nitems] = 0;
|
||||||
codepage = CP_UTF8; // code page identifier for utf8
|
codepage = CP_UTF8; // code page identifier for utf8
|
||||||
} else if (xtpText_encoding == XCB_ATOM_STRING) {
|
} else if (xtpText_encoding == XCB_ATOM_STRING) {
|
||||||
// STRING encoding is Latin1 (ISO8859-1) plus tab and newline
|
// STRING encoding is Latin1 (ISO8859-1) plus tab and newline
|
||||||
pszReturnData = malloc(xtpText_nitems + 1);
|
pszReturnData = calloc(1, xtpText_nitems + 1);
|
||||||
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
||||||
pszReturnData[xtpText_nitems] = 0;
|
pszReturnData[xtpText_nitems] = 0;
|
||||||
codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1
|
codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1
|
||||||
} else if (xtpText_encoding == atoms->atomCompoundText) {
|
} else if (xtpText_encoding == atoms->atomCompoundText) {
|
||||||
// COMPOUND_TEXT is complex, based on ISO 2022
|
// COMPOUND_TEXT is complex, based on ISO 2022
|
||||||
ErrorF("SelectionNotify: data in COMPOUND_TEXT encoding which is not implemented, discarding\n");
|
ErrorF("SelectionNotify: data in COMPOUND_TEXT encoding which is not implemented, discarding\n");
|
||||||
pszReturnData = malloc(1);
|
pszReturnData = calloc(1, 1);
|
||||||
pszReturnData[0] = '\0';
|
pszReturnData[0] = '\0';
|
||||||
} else { // shouldn't happen as we accept no other encodings
|
} else { // shouldn't happen as we accept no other encodings
|
||||||
pszReturnData = malloc(1);
|
pszReturnData = calloc(1, 1);
|
||||||
pszReturnData[0] = '\0';
|
pszReturnData[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,10 +314,10 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
||||||
pszReturnData, -1, NULL, 0);
|
pszReturnData, -1, NULL, 0);
|
||||||
|
|
||||||
/* NOTE: iUnicodeLen includes space for null terminator */
|
/* NOTE: iUnicodeLen includes space for null terminator */
|
||||||
pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen);
|
pwszUnicodeStr = calloc(iUnicodeLen, sizeof(wchar_t));
|
||||||
if (!pwszUnicodeStr) {
|
if (!pwszUnicodeStr) {
|
||||||
ErrorF("winClipboardFlushXEvents - SelectionNotify "
|
ErrorF("winClipboardFlushXEvents - SelectionNotify "
|
||||||
"malloc failed for pwszUnicodeStr, aborting.\n");
|
"calloc failed for pwszUnicodeStr, aborting.\n");
|
||||||
|
|
||||||
/* Abort */
|
/* Abort */
|
||||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||||
|
@ -551,7 +551,7 @@ winClipboardFlushXEvents(HWND hwnd,
|
||||||
(LPCWSTR) pszGlobalData, -1,
|
(LPCWSTR) pszGlobalData, -1,
|
||||||
NULL, 0, NULL, NULL);
|
NULL, 0, NULL, NULL);
|
||||||
/* NOTE: iConvertDataLen includes space for null terminator */
|
/* NOTE: iConvertDataLen includes space for null terminator */
|
||||||
pszConvertData = malloc(iConvertDataLen);
|
pszConvertData = calloc(1, iConvertDataLen);
|
||||||
WideCharToMultiByte(codepage, 0,
|
WideCharToMultiByte(codepage, 0,
|
||||||
(LPCWSTR) pszGlobalData, -1,
|
(LPCWSTR) pszGlobalData, -1,
|
||||||
pszConvertData, iConvertDataLen, NULL, NULL);
|
pszConvertData, iConvertDataLen, NULL, NULL);
|
||||||
|
|
|
@ -405,7 +405,6 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
|
||||||
Pixel pixel; /* Pixel == CARD32 */
|
Pixel pixel; /* Pixel == CARD32 */
|
||||||
CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
|
CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
|
||||||
UINT uiSystemPaletteEntries;
|
UINT uiSystemPaletteEntries;
|
||||||
LPPALETTEENTRY ppeColors = NULL;
|
|
||||||
HDC hdc = NULL;
|
HDC hdc = NULL;
|
||||||
|
|
||||||
/* Get a DC to obtain the default palette */
|
/* Get a DC to obtain the default palette */
|
||||||
|
@ -429,9 +428,9 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate palette entries structure */
|
/* Allocate palette entries structure */
|
||||||
ppeColors = malloc(uiSystemPaletteEntries * sizeof(PALETTEENTRY));
|
LPPALETTEENTRY ppeColors = calloc(uiSystemPaletteEntries, sizeof(PALETTEENTRY));
|
||||||
if (ppeColors == NULL) {
|
if (ppeColors == NULL) {
|
||||||
ErrorF("winGetPaletteDD - malloc () for colormap failed\n");
|
ErrorF("winGetPaletteDD - calloc () for colormap failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,10 +294,9 @@ winConfigKeyboard(DeviceIntPtr pDevice)
|
||||||
HKEY regkey = NULL;
|
HKEY regkey = NULL;
|
||||||
const char regtempl[] =
|
const char regtempl[] =
|
||||||
"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
|
"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
|
||||||
char *regpath;
|
|
||||||
DWORD namesize = sizeof(layoutFriendlyName);
|
DWORD namesize = sizeof(layoutFriendlyName);
|
||||||
|
|
||||||
regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
|
char *regpath = calloc(1, sizeof(regtempl) + KL_NAMELENGTH + 1);
|
||||||
strcpy(regpath, regtempl);
|
strcpy(regpath, regtempl);
|
||||||
strcat(regpath, layoutName);
|
strcat(regpath, layoutName);
|
||||||
|
|
||||||
|
@ -907,7 +906,7 @@ ParseOptionValue(int scrnIndex, void *options, OptionInfoPtr p)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
free(n);
|
free(n);
|
||||||
n = malloc(strlen(p->name) + 2 + 1);
|
n = calloc(1, strlen(p->name) + 2 + 1);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -995,13 +994,13 @@ GetBoolValue(OptionInfoPtr p, const char *s)
|
||||||
char *
|
char *
|
||||||
winNormalizeName(const char *s)
|
winNormalizeName(const char *s)
|
||||||
{
|
{
|
||||||
char *ret, *q;
|
char *q;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret = malloc(strlen(s) + 1);
|
char *ret = calloc(1, strlen(s) + 1);
|
||||||
for (p = s, q = ret; *p != 0; p++) {
|
for (p = s, q = ret; *p != 0; p++) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case '_':
|
case '_':
|
||||||
|
|
|
@ -150,7 +150,6 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
|
||||||
{
|
{
|
||||||
winScreenPriv(pScreen);
|
winScreenPriv(pScreen);
|
||||||
HCURSOR hCursor = NULL;
|
HCURSOR hCursor = NULL;
|
||||||
unsigned char *pAnd;
|
|
||||||
unsigned char *pXor;
|
unsigned char *pXor;
|
||||||
int nCX, nCY;
|
int nCX, nCY;
|
||||||
int nBytes;
|
int nBytes;
|
||||||
|
@ -196,7 +195,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
|
||||||
nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
|
nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
|
||||||
|
|
||||||
/* Allocate memory for the bitmaps */
|
/* Allocate memory for the bitmaps */
|
||||||
pAnd = malloc(nBytes);
|
unsigned char *pAnd = calloc(1, nBytes);
|
||||||
memset(pAnd, 0xFF, nBytes);
|
memset(pAnd, 0xFF, nBytes);
|
||||||
pXor = calloc(1, nBytes);
|
pXor = calloc(1, nBytes);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
{
|
{
|
||||||
int lngMouseButtons, i;
|
int lngMouseButtons, i;
|
||||||
int lngWheelEvents = 4;
|
int lngWheelEvents = 4;
|
||||||
CARD8 *map;
|
|
||||||
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
||||||
Atom btn_labels[9];
|
Atom btn_labels[9];
|
||||||
Atom axes_labels[2];
|
Atom axes_labels[2];
|
||||||
|
@ -98,7 +97,7 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
/* allocate memory:
|
/* allocate memory:
|
||||||
* number of buttons + 4 x mouse wheel event + 1 extra (offset for map)
|
* number of buttons + 4 x mouse wheel event + 1 extra (offset for map)
|
||||||
*/
|
*/
|
||||||
map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
|
CARD8 *map = calloc(lngMouseButtons + lngWheelEvents + 1, sizeof(CARD8));
|
||||||
|
|
||||||
/* initialize button map */
|
/* initialize button map */
|
||||||
map[0] = 0;
|
map[0] = 0;
|
||||||
|
|
|
@ -68,7 +68,7 @@ winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class)
|
||||||
len_name = strlen((char *) prop->data);
|
len_name = strlen((char *) prop->data);
|
||||||
if (len_name > prop->size) len_name = prop->size;
|
if (len_name > prop->size) len_name = prop->size;
|
||||||
|
|
||||||
(*res_name) = malloc(len_name + 1);
|
(*res_name) = calloc(1, len_name + 1);
|
||||||
|
|
||||||
if (!*res_name) {
|
if (!*res_name) {
|
||||||
ErrorF("winMultiWindowGetClassHint - *res_name was NULL\n");
|
ErrorF("winMultiWindowGetClassHint - *res_name was NULL\n");
|
||||||
|
@ -83,7 +83,7 @@ winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class)
|
||||||
len_class = (len_name >= prop->size) ? 0 : (strlen(((char *) prop->data) + 1 + len_name));
|
len_class = (len_name >= prop->size) ? 0 : (strlen(((char *) prop->data) + 1 + len_name));
|
||||||
if (len_class > prop->size - 1 - len_name) len_class = prop->size - 1 - len_name;
|
if (len_class > prop->size - 1 - len_name) len_class = prop->size - 1 - len_name;
|
||||||
|
|
||||||
(*res_class) = malloc(len_class + 1);
|
(*res_class) = calloc(1, len_class + 1);
|
||||||
|
|
||||||
if (!*res_class) {
|
if (!*res_class) {
|
||||||
ErrorF("winMultiWindowGetClassHint - *res_class was NULL\n");
|
ErrorF("winMultiWindowGetClassHint - *res_class was NULL\n");
|
||||||
|
@ -146,7 +146,7 @@ winMultiWindowGetWindowRole(WindowPtr pWin, char **res_role)
|
||||||
&& prop->type == XA_STRING && prop->format == 8 && prop->data) {
|
&& prop->type == XA_STRING && prop->format == 8 && prop->data) {
|
||||||
len_role = prop->size;
|
len_role = prop->size;
|
||||||
|
|
||||||
(*res_role) = malloc(len_role + 1);
|
(*res_role) = calloc(1, len_role + 1);
|
||||||
|
|
||||||
if (!*res_role) {
|
if (!*res_role) {
|
||||||
ErrorF("winMultiWindowGetWindowRole - *res_role was NULL\n");
|
ErrorF("winMultiWindowGetWindowRole - *res_role was NULL\n");
|
||||||
|
@ -235,7 +235,7 @@ winMultiWindowGetWMName(WindowPtr pWin, char **wmName)
|
||||||
&& prop->type == XA_STRING && prop->data) {
|
&& prop->type == XA_STRING && prop->data) {
|
||||||
len_name = prop->size;
|
len_name = prop->size;
|
||||||
|
|
||||||
(*wmName) = malloc(len_name + 1);
|
(*wmName) = calloc(1, len_name + 1);
|
||||||
|
|
||||||
if (!*wmName) {
|
if (!*wmName) {
|
||||||
ErrorF("winMultiWindowGetWMName - *wmName was NULL\n");
|
ErrorF("winMultiWindowGetWMName - *wmName was NULL\n");
|
||||||
|
|
|
@ -513,9 +513,9 @@ winXIconToHICON(xcb_connection_t *conn, xcb_window_t id, int iconSize)
|
||||||
/* Mask is 1-bit deep */
|
/* Mask is 1-bit deep */
|
||||||
maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
|
maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
|
||||||
|
|
||||||
image = malloc(stride * iconSize);
|
image = calloc(stride, iconSize);
|
||||||
imageMask = malloc(stride * iconSize);
|
imageMask = calloc(stride, iconSize);
|
||||||
mask = malloc(maskStride * iconSize);
|
mask = calloc(maskStride, iconSize);
|
||||||
|
|
||||||
/* Default to a completely black mask */
|
/* Default to a completely black mask */
|
||||||
memset(imageMask, 0, stride * iconSize);
|
memset(imageMask, 0, stride * iconSize);
|
||||||
|
|
|
@ -872,13 +872,12 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
|
||||||
static HBITMAP winCreateDIB(ScreenPtr pScreen, int width, int height, int bpp, void **ppvBits, BITMAPINFOHEADER **ppbmih)
|
static HBITMAP winCreateDIB(ScreenPtr pScreen, int width, int height, int bpp, void **ppvBits, BITMAPINFOHEADER **ppbmih)
|
||||||
{
|
{
|
||||||
winScreenPriv(pScreen);
|
winScreenPriv(pScreen);
|
||||||
BITMAPV4HEADER *pbmih = NULL;
|
|
||||||
HBITMAP hBitmap = NULL;
|
HBITMAP hBitmap = NULL;
|
||||||
|
|
||||||
/* Allocate bitmap info header */
|
/* Allocate bitmap info header */
|
||||||
pbmih = malloc(sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
BITMAPV4HEADER *pbmih = calloc(1, sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
||||||
if (pbmih == NULL) {
|
if (pbmih == NULL) {
|
||||||
ErrorF("winCreateDIB: malloc() failed\n");
|
ErrorF("winCreateDIB: calloc() failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(pbmih, 0, sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
memset(pbmih, 0, sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
||||||
|
|
|
@ -458,7 +458,7 @@ GetWindowName(WMInfoPtr pWMInfo, xcb_window_t iWin, char **ppWindowName)
|
||||||
(strstr(pszWindowName, pszClientHostname) == 0)) {
|
(strstr(pszWindowName, pszClientHostname) == 0)) {
|
||||||
/* ... add '@<clientmachine>' to end of window name */
|
/* ... add '@<clientmachine>' to end of window name */
|
||||||
*ppWindowName =
|
*ppWindowName =
|
||||||
malloc(strlen(pszWindowName) +
|
calloc(1, strlen(pszWindowName) +
|
||||||
strlen(pszClientMachine) + 2);
|
strlen(pszClientMachine) + 2);
|
||||||
strcpy(*ppWindowName, pszWindowName);
|
strcpy(*ppWindowName, pszWindowName);
|
||||||
strcat(*ppWindowName, "@");
|
strcat(*ppWindowName, "@");
|
||||||
|
@ -634,8 +634,7 @@ UpdateName(WMInfoPtr pWMInfo, xcb_window_t iWindow)
|
||||||
/* Convert from UTF-8 to wide char */
|
/* Convert from UTF-8 to wide char */
|
||||||
int iLen =
|
int iLen =
|
||||||
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0);
|
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0);
|
||||||
wchar_t *pwszWideWindowName =
|
wchar_t *pwszWideWindowName = calloc(iLen + 1, sizeof(wchar_t));
|
||||||
malloc(sizeof(wchar_t)*(iLen + 1));
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1,
|
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1,
|
||||||
pwszWideWindowName, iLen);
|
pwszWideWindowName, iLen);
|
||||||
|
|
||||||
|
@ -1401,7 +1400,7 @@ winInitWM(void **ppWMInfo,
|
||||||
|
|
||||||
/* Bail if the input parameters are bad */
|
/* Bail if the input parameters are bad */
|
||||||
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
|
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
|
||||||
ErrorF("winInitWM - malloc failed.\n");
|
ErrorF("winInitWM - calloc failed.\n");
|
||||||
free(pArg);
|
free(pArg);
|
||||||
free(pWMInfo);
|
free(pWMInfo);
|
||||||
free(pXMsgArg);
|
free(pXMsgArg);
|
||||||
|
@ -1629,13 +1628,12 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
|
||||||
void
|
void
|
||||||
winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
|
winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
|
||||||
{
|
{
|
||||||
WMMsgNodePtr pNode;
|
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
#if ENABLE_DEBUG
|
||||||
ErrorF("winSendMessageToWM %s\n", MessageName(pMsg));
|
ErrorF("winSendMessageToWM %s\n", MessageName(pMsg));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pNode = malloc(sizeof(WMMsgNodeRec));
|
WMMsgNodePtr pNode = calloc(1, sizeof(WMMsgNodeRec));
|
||||||
if (pNode != NULL) {
|
if (pNode != NULL) {
|
||||||
memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec));
|
memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec));
|
||||||
PushMessage(&((WMInfoPtr) pWMInfo)->wmMsgQueue, pNode);
|
PushMessage(&((WMInfoPtr) pWMInfo)->wmMsgQueue, pNode);
|
||||||
|
|
|
@ -541,7 +541,7 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags)
|
||||||
MAKEINTRESOURCE(i), IMAGE_ICON, sx, sy, flags);
|
MAKEINTRESOURCE(i), IMAGE_ICON, sx, sy, flags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *file = malloc(PATH_MAX + NAME_MAX + 2);
|
char *file = calloc(1, PATH_MAX + NAME_MAX + 2);
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
Bool convert = FALSE;
|
Bool convert = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -752,7 +752,7 @@ LoadPreferences(void)
|
||||||
/* Setup a DISPLAY environment variable, need to allocate on heap */
|
/* Setup a DISPLAY environment variable, need to allocate on heap */
|
||||||
/* because putenv doesn't copy the argument... */
|
/* because putenv doesn't copy the argument... */
|
||||||
winGetDisplayName(szDisplay, 0);
|
winGetDisplayName(szDisplay, 0);
|
||||||
szEnvDisplay = (char *) (malloc(strlen(szDisplay) + strlen("DISPLAY=") + 1));
|
szEnvDisplay = calloc(1, strlen(szDisplay) + strlen("DISPLAY=") + 1);
|
||||||
if (szEnvDisplay) {
|
if (szEnvDisplay) {
|
||||||
snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
|
snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
|
||||||
putenv(szEnvDisplay);
|
putenv(szEnvDisplay);
|
||||||
|
|
|
@ -42,8 +42,7 @@ extern void ErrorF (const char* /*f*/, ...);
|
||||||
/* Copy the parsed string, must be free()d in yacc parser */
|
/* Copy the parsed string, must be free()d in yacc parser */
|
||||||
static char *makestr(char *str)
|
static char *makestr(char *str)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr = calloc(1, strlen(str)+1);
|
||||||
ptr = malloc(strlen(str)+1);
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
ErrorF ("winMultiWindowLex:makestr() out of memory\n");
|
ErrorF ("winMultiWindowLex:makestr() out of memory\n");
|
||||||
|
|
|
@ -310,7 +310,7 @@ static void
|
||||||
AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
|
AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
|
||||||
{
|
{
|
||||||
if (menu.menuItem==NULL)
|
if (menu.menuItem==NULL)
|
||||||
menu.menuItem = malloc(sizeof(MENUITEM));
|
menu.menuItem = calloc(1, sizeof(MENUITEM));
|
||||||
else
|
else
|
||||||
menu.menuItem = realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
|
menu.menuItem = realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ CloseMenu (void)
|
||||||
if (pref.menuItems)
|
if (pref.menuItems)
|
||||||
pref.menu = realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
|
pref.menu = realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
|
||||||
else
|
else
|
||||||
pref.menu = malloc (sizeof(MENUPARSED));
|
pref.menu = calloc(1, sizeof(MENUPARSED));
|
||||||
|
|
||||||
memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
|
memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
|
||||||
pref.menuItems++;
|
pref.menuItems++;
|
||||||
|
@ -362,7 +362,7 @@ static void
|
||||||
AddIconLine (char *matchstr, char *iconfile)
|
AddIconLine (char *matchstr, char *iconfile)
|
||||||
{
|
{
|
||||||
if (pref.icon==NULL)
|
if (pref.icon==NULL)
|
||||||
pref.icon = malloc(sizeof(ICONITEM));
|
pref.icon = calloc(1, sizeof(ICONITEM));
|
||||||
else
|
else
|
||||||
pref.icon = realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
|
pref.icon = realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ static void
|
||||||
AddStyleLine (char *matchstr, unsigned long style)
|
AddStyleLine (char *matchstr, unsigned long style)
|
||||||
{
|
{
|
||||||
if (pref.style==NULL)
|
if (pref.style==NULL)
|
||||||
pref.style = malloc(sizeof(STYLEITEM));
|
pref.style = calloc(1, sizeof(STYLEITEM));
|
||||||
else
|
else
|
||||||
pref.style = realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
|
pref.style = realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ static void
|
||||||
AddSysMenuLine (char *matchstr, char *menuname, int pos)
|
AddSysMenuLine (char *matchstr, char *menuname, int pos)
|
||||||
{
|
{
|
||||||
if (pref.sysMenu==NULL)
|
if (pref.sysMenu==NULL)
|
||||||
pref.sysMenu = malloc(sizeof(SYSMENUITEM));
|
pref.sysMenu = calloc(1, sizeof(SYSMENUITEM));
|
||||||
else
|
else
|
||||||
pref.sysMenu = realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
|
pref.sysMenu = realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
|
||||||
|
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ winLogCommandLine(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for concatenated command line */
|
/* Allocate memory for concatenated command line */
|
||||||
g_pszCommandLine = malloc(iSize + 1);
|
g_pszCommandLine = calloc(1, iSize + 1);
|
||||||
if (!g_pszCommandLine)
|
if (!g_pszCommandLine)
|
||||||
FatalError("winLogCommandLine - Could not allocate memory for "
|
FatalError("winLogCommandLine - Could not allocate memory for "
|
||||||
"command line string. Exiting.\n");
|
"command line string. Exiting.\n");
|
||||||
|
|
|
@ -266,14 +266,14 @@ winRandRInit(ScreenPtr pScreen)
|
||||||
output->crtc = crtc;
|
output->crtc = crtc;
|
||||||
|
|
||||||
/* Set crtc outputs (should use RRCrtcNotify?) */
|
/* Set crtc outputs (should use RRCrtcNotify?) */
|
||||||
crtc->outputs = malloc(sizeof(RROutputPtr));
|
crtc->outputs = calloc(1, sizeof(RROutputPtr));
|
||||||
crtc->outputs[0] = output;
|
crtc->outputs[0] = output;
|
||||||
crtc->numOutputs = 1;
|
crtc->numOutputs = 1;
|
||||||
|
|
||||||
pRRScrPriv->primaryOutput = output;
|
pRRScrPriv->primaryOutput = output;
|
||||||
|
|
||||||
/* Ensure we have space for exactly one mode */
|
/* Ensure we have space for exactly one mode */
|
||||||
output->modes = malloc(sizeof(RRModePtr));
|
output->modes = calloc(1, sizeof(RRModePtr));
|
||||||
output->modes[0] = NULL;
|
output->modes[0] = NULL;
|
||||||
|
|
||||||
/* Set mode to current display size */
|
/* Set mode to current display size */
|
||||||
|
|
|
@ -151,7 +151,6 @@ static
|
||||||
winQueryRGBBitsAndMasks(ScreenPtr pScreen)
|
winQueryRGBBitsAndMasks(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
winScreenPriv(pScreen);
|
winScreenPriv(pScreen);
|
||||||
BITMAPINFOHEADER *pbmih = NULL;
|
|
||||||
Bool fReturn = TRUE;
|
Bool fReturn = TRUE;
|
||||||
LPDWORD pdw = NULL;
|
LPDWORD pdw = NULL;
|
||||||
DWORD dwRedBits, dwGreenBits, dwBlueBits;
|
DWORD dwRedBits, dwGreenBits, dwBlueBits;
|
||||||
|
@ -187,9 +186,9 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a bitmap header and color table */
|
/* Allocate a bitmap header and color table */
|
||||||
pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
BITMAPINFOHEADER *pbmih = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
||||||
if (pbmih == NULL) {
|
if (pbmih == NULL) {
|
||||||
ErrorF("winQueryRGBBitsAndMasks - malloc failed\n");
|
ErrorF("winQueryRGBBitsAndMasks - calloc failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,9 +540,9 @@ winInitScreenShadowGDI(ScreenPtr pScreen)
|
||||||
pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen);
|
pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen);
|
||||||
|
|
||||||
/* Allocate bitmap info header */
|
/* Allocate bitmap info header */
|
||||||
pScreenPriv->pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
pScreenPriv->pbmih = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
||||||
if (pScreenPriv->pbmih == NULL) {
|
if (pScreenPriv->pbmih == NULL) {
|
||||||
ErrorF("winInitScreenShadowGDI - malloc () failed\n");
|
ErrorF("winInitScreenShadowGDI - calloc () failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue