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 */
|
||||
if (fontpath == NULL)
|
||||
fontpath = malloc(newsize + 1);
|
||||
fontpath = calloc(1, newsize + 1);
|
||||
else
|
||||
fontpath = realloc(fontpath, newsize + 1);
|
||||
|
||||
|
@ -509,7 +509,7 @@ winFixupPaths(void)
|
|||
while (ptr != NULL) {
|
||||
size_t oldfp_len = (ptr - oldptr);
|
||||
size_t newsize = oldfp_len;
|
||||
char *newpath = malloc(newsize + 1);
|
||||
char *newpath = calloc(1, newsize + 1);
|
||||
|
||||
strncpy(newpath, oldptr, newsize);
|
||||
newpath[newsize] = 0;
|
||||
|
@ -518,7 +518,7 @@ winFixupPaths(void)
|
|||
char *compose;
|
||||
|
||||
newsize = newsize - libx11dir_len + basedirlen;
|
||||
compose = malloc(newsize + 1);
|
||||
compose = calloc(1, newsize + 1);
|
||||
strcpy(compose, basedir);
|
||||
strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
|
||||
compose[newsize] = 0;
|
||||
|
@ -532,7 +532,7 @@ winFixupPaths(void)
|
|||
newfp_len += newsize;
|
||||
|
||||
if (newfp == NULL)
|
||||
newfp = malloc(newfp_len + 1);
|
||||
newfp = calloc(1, newfp_len + 1);
|
||||
else
|
||||
newfp = realloc(newfp, newfp_len + 1);
|
||||
|
||||
|
|
|
@ -843,9 +843,7 @@ glxWinCreateDrawable(ClientPtr client,
|
|||
DrawablePtr pDraw,
|
||||
XID drawId, int type, XID glxDrawId, __GLXconfig * conf)
|
||||
{
|
||||
__GLXWinDrawable *glxPriv;
|
||||
|
||||
glxPriv = malloc(sizeof *glxPriv);
|
||||
__GLXWinDrawable *glxPriv = calloc(1, sizeof *glxPriv);
|
||||
|
||||
if (glxPriv == NULL)
|
||||
return NULL;
|
||||
|
@ -1969,7 +1967,7 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
|
|||
n++;
|
||||
|
||||
// allocate and save
|
||||
work = malloc(sizeof(GLXWinConfig));
|
||||
work = calloc(1, sizeof(GLXWinConfig));
|
||||
if (NULL == work) {
|
||||
ErrorF("Failed to allocate GLXWinConfig\n");
|
||||
break;
|
||||
|
@ -2383,7 +2381,7 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats *
|
|||
n++;
|
||||
|
||||
// allocate and save
|
||||
work = malloc(sizeof(GLXWinConfig));
|
||||
work = calloc(1, sizeof(GLXWinConfig));
|
||||
if (NULL == work) {
|
||||
ErrorF("Failed to allocate GLXWinConfig\n");
|
||||
break;
|
||||
|
|
|
@ -81,10 +81,6 @@ GenerateAuthorization(unsigned name_length,
|
|||
BOOL
|
||||
winGenerateAuthorization(void)
|
||||
{
|
||||
#ifdef XCSECURITY
|
||||
SecurityAuthorizationPtr pAuth = NULL;
|
||||
#endif
|
||||
|
||||
/* Call OS layer to generate authorization key */
|
||||
g_authId = GenerateAuthorization(strlen(AUTH_NAME),
|
||||
AUTH_NAME,
|
||||
|
@ -107,8 +103,7 @@ winGenerateAuthorization(void)
|
|||
|
||||
#ifdef XCSECURITY
|
||||
/* Allocate structure for additional auth information */
|
||||
pAuth = (SecurityAuthorizationPtr)
|
||||
malloc(sizeof(SecurityAuthorizationRec));
|
||||
SecurityAuthorizationPtr pAuth = calloc(1, sizeof(SecurityAuthorizationRec));
|
||||
if (!(pAuth)) {
|
||||
ErrorF("winGenerateAuthorization - Failed allocating "
|
||||
"SecurityAuthorizationPtr.\n");
|
||||
|
|
|
@ -100,7 +100,7 @@ winClipboardUNIXtoDOS(char **ppszData, int iLength)
|
|||
return;
|
||||
|
||||
/* 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 */
|
||||
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);
|
||||
if (!reply)
|
||||
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) {
|
||||
memcpy(ret, xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||
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);
|
||||
int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t);
|
||||
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++)
|
||||
{
|
||||
|
@ -242,8 +242,8 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
|||
if (encoding == atoms->atomIncr) {
|
||||
winDebug("winClipboardSelectionNotifyData: starting INCR, anticipated size %d\n", *(int *)value);
|
||||
data->incrsize = 0;
|
||||
data->incr = malloc(*(int *)value);
|
||||
// XXX: if malloc failed, we have an error
|
||||
data->incr = calloc(1, *(int *)value);
|
||||
// XXX: if calloc failed, we have an error
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
}
|
||||
else if (data->incr) {
|
||||
|
@ -276,23 +276,23 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
|||
}
|
||||
|
||||
if (xtpText_encoding == atoms->atomUTF8String) {
|
||||
pszReturnData = malloc(xtpText_nitems + 1);
|
||||
pszReturnData = calloc(1, xtpText_nitems + 1);
|
||||
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
||||
pszReturnData[xtpText_nitems] = 0;
|
||||
codepage = CP_UTF8; // code page identifier for utf8
|
||||
} else if (xtpText_encoding == XCB_ATOM_STRING) {
|
||||
// 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);
|
||||
pszReturnData[xtpText_nitems] = 0;
|
||||
codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1
|
||||
} else if (xtpText_encoding == atoms->atomCompoundText) {
|
||||
// COMPOUND_TEXT is complex, based on ISO 2022
|
||||
ErrorF("SelectionNotify: data in COMPOUND_TEXT encoding which is not implemented, discarding\n");
|
||||
pszReturnData = malloc(1);
|
||||
pszReturnData = calloc(1, 1);
|
||||
pszReturnData[0] = '\0';
|
||||
} else { // shouldn't happen as we accept no other encodings
|
||||
pszReturnData = malloc(1);
|
||||
pszReturnData = calloc(1, 1);
|
||||
pszReturnData[0] = '\0';
|
||||
}
|
||||
|
||||
|
@ -314,10 +314,10 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_
|
|||
pszReturnData, -1, NULL, 0);
|
||||
|
||||
/* NOTE: iUnicodeLen includes space for null terminator */
|
||||
pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen);
|
||||
pwszUnicodeStr = calloc(iUnicodeLen, sizeof(wchar_t));
|
||||
if (!pwszUnicodeStr) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify "
|
||||
"malloc failed for pwszUnicodeStr, aborting.\n");
|
||||
"calloc failed for pwszUnicodeStr, aborting.\n");
|
||||
|
||||
/* Abort */
|
||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||
|
@ -551,7 +551,7 @@ winClipboardFlushXEvents(HWND hwnd,
|
|||
(LPCWSTR) pszGlobalData, -1,
|
||||
NULL, 0, NULL, NULL);
|
||||
/* NOTE: iConvertDataLen includes space for null terminator */
|
||||
pszConvertData = malloc(iConvertDataLen);
|
||||
pszConvertData = calloc(1, iConvertDataLen);
|
||||
WideCharToMultiByte(codepage, 0,
|
||||
(LPCWSTR) pszGlobalData, -1,
|
||||
pszConvertData, iConvertDataLen, NULL, NULL);
|
||||
|
|
|
@ -405,7 +405,6 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
|
|||
Pixel pixel; /* Pixel == CARD32 */
|
||||
CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
|
||||
UINT uiSystemPaletteEntries;
|
||||
LPPALETTEENTRY ppeColors = NULL;
|
||||
HDC hdc = NULL;
|
||||
|
||||
/* Get a DC to obtain the default palette */
|
||||
|
@ -429,9 +428,9 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
|
|||
#endif
|
||||
|
||||
/* Allocate palette entries structure */
|
||||
ppeColors = malloc(uiSystemPaletteEntries * sizeof(PALETTEENTRY));
|
||||
LPPALETTEENTRY ppeColors = calloc(uiSystemPaletteEntries, sizeof(PALETTEENTRY));
|
||||
if (ppeColors == NULL) {
|
||||
ErrorF("winGetPaletteDD - malloc () for colormap failed\n");
|
||||
ErrorF("winGetPaletteDD - calloc () for colormap failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -294,10 +294,9 @@ winConfigKeyboard(DeviceIntPtr pDevice)
|
|||
HKEY regkey = NULL;
|
||||
const char regtempl[] =
|
||||
"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
|
||||
char *regpath;
|
||||
DWORD namesize = sizeof(layoutFriendlyName);
|
||||
|
||||
regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
|
||||
char *regpath = calloc(1, sizeof(regtempl) + KL_NAMELENGTH + 1);
|
||||
strcpy(regpath, regtempl);
|
||||
strcat(regpath, layoutName);
|
||||
|
||||
|
@ -907,7 +906,7 @@ ParseOptionValue(int scrnIndex, void *options, OptionInfoPtr p)
|
|||
}
|
||||
else {
|
||||
free(n);
|
||||
n = malloc(strlen(p->name) + 2 + 1);
|
||||
n = calloc(1, strlen(p->name) + 2 + 1);
|
||||
if (!n) {
|
||||
p->found = FALSE;
|
||||
return FALSE;
|
||||
|
@ -995,13 +994,13 @@ GetBoolValue(OptionInfoPtr p, const char *s)
|
|||
char *
|
||||
winNormalizeName(const char *s)
|
||||
{
|
||||
char *ret, *q;
|
||||
char *q;
|
||||
const char *p;
|
||||
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = malloc(strlen(s) + 1);
|
||||
char *ret = calloc(1, strlen(s) + 1);
|
||||
for (p = s, q = ret; *p != 0; p++) {
|
||||
switch (*p) {
|
||||
case '_':
|
||||
|
|
|
@ -150,7 +150,6 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
|
|||
{
|
||||
winScreenPriv(pScreen);
|
||||
HCURSOR hCursor = NULL;
|
||||
unsigned char *pAnd;
|
||||
unsigned char *pXor;
|
||||
int nCX, nCY;
|
||||
int nBytes;
|
||||
|
@ -196,7 +195,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
|
|||
nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
|
||||
|
||||
/* Allocate memory for the bitmaps */
|
||||
pAnd = malloc(nBytes);
|
||||
unsigned char *pAnd = calloc(1, nBytes);
|
||||
memset(pAnd, 0xFF, nBytes);
|
||||
pXor = calloc(1, nBytes);
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
|||
{
|
||||
int lngMouseButtons, i;
|
||||
int lngWheelEvents = 4;
|
||||
CARD8 *map;
|
||||
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
||||
Atom btn_labels[9];
|
||||
Atom axes_labels[2];
|
||||
|
@ -98,7 +97,7 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
|||
/* allocate memory:
|
||||
* 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 */
|
||||
map[0] = 0;
|
||||
|
|
|
@ -68,7 +68,7 @@ winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class)
|
|||
len_name = strlen((char *) prop->data);
|
||||
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) {
|
||||
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));
|
||||
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) {
|
||||
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) {
|
||||
len_role = prop->size;
|
||||
|
||||
(*res_role) = malloc(len_role + 1);
|
||||
(*res_role) = calloc(1, len_role + 1);
|
||||
|
||||
if (!*res_role) {
|
||||
ErrorF("winMultiWindowGetWindowRole - *res_role was NULL\n");
|
||||
|
@ -235,7 +235,7 @@ winMultiWindowGetWMName(WindowPtr pWin, char **wmName)
|
|||
&& prop->type == XA_STRING && prop->data) {
|
||||
len_name = prop->size;
|
||||
|
||||
(*wmName) = malloc(len_name + 1);
|
||||
(*wmName) = calloc(1, len_name + 1);
|
||||
|
||||
if (!*wmName) {
|
||||
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 */
|
||||
maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
|
||||
|
||||
image = malloc(stride * iconSize);
|
||||
imageMask = malloc(stride * iconSize);
|
||||
mask = malloc(maskStride * iconSize);
|
||||
image = calloc(stride, iconSize);
|
||||
imageMask = calloc(stride, iconSize);
|
||||
mask = calloc(maskStride, iconSize);
|
||||
|
||||
/* Default to a completely black mask */
|
||||
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)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
BITMAPV4HEADER *pbmih = NULL;
|
||||
HBITMAP hBitmap = NULL;
|
||||
|
||||
/* Allocate bitmap info header */
|
||||
pbmih = malloc(sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
||||
BITMAPV4HEADER *pbmih = calloc(1, sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD));
|
||||
if (pbmih == NULL) {
|
||||
ErrorF("winCreateDIB: malloc() failed\n");
|
||||
ErrorF("winCreateDIB: calloc() failed\n");
|
||||
return NULL;
|
||||
}
|
||||
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)) {
|
||||
/* ... add '@<clientmachine>' to end of window name */
|
||||
*ppWindowName =
|
||||
malloc(strlen(pszWindowName) +
|
||||
calloc(1, strlen(pszWindowName) +
|
||||
strlen(pszClientMachine) + 2);
|
||||
strcpy(*ppWindowName, pszWindowName);
|
||||
strcat(*ppWindowName, "@");
|
||||
|
@ -634,8 +634,7 @@ UpdateName(WMInfoPtr pWMInfo, xcb_window_t iWindow)
|
|||
/* Convert from UTF-8 to wide char */
|
||||
int iLen =
|
||||
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0);
|
||||
wchar_t *pwszWideWindowName =
|
||||
malloc(sizeof(wchar_t)*(iLen + 1));
|
||||
wchar_t *pwszWideWindowName = calloc(iLen + 1, sizeof(wchar_t));
|
||||
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1,
|
||||
pwszWideWindowName, iLen);
|
||||
|
||||
|
@ -1401,7 +1400,7 @@ winInitWM(void **ppWMInfo,
|
|||
|
||||
/* Bail if the input parameters are bad */
|
||||
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
|
||||
ErrorF("winInitWM - malloc failed.\n");
|
||||
ErrorF("winInitWM - calloc failed.\n");
|
||||
free(pArg);
|
||||
free(pWMInfo);
|
||||
free(pXMsgArg);
|
||||
|
@ -1629,13 +1628,12 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
|
|||
void
|
||||
winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
|
||||
{
|
||||
WMMsgNodePtr pNode;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
ErrorF("winSendMessageToWM %s\n", MessageName(pMsg));
|
||||
#endif
|
||||
|
||||
pNode = malloc(sizeof(WMMsgNodeRec));
|
||||
WMMsgNodePtr pNode = calloc(1, sizeof(WMMsgNodeRec));
|
||||
if (pNode != NULL) {
|
||||
memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec));
|
||||
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);
|
||||
}
|
||||
else {
|
||||
char *file = malloc(PATH_MAX + NAME_MAX + 2);
|
||||
char *file = calloc(1, PATH_MAX + NAME_MAX + 2);
|
||||
#ifdef __CYGWIN__
|
||||
Bool convert = FALSE;
|
||||
#endif
|
||||
|
@ -752,7 +752,7 @@ LoadPreferences(void)
|
|||
/* Setup a DISPLAY environment variable, need to allocate on heap */
|
||||
/* because putenv doesn't copy the argument... */
|
||||
winGetDisplayName(szDisplay, 0);
|
||||
szEnvDisplay = (char *) (malloc(strlen(szDisplay) + strlen("DISPLAY=") + 1));
|
||||
szEnvDisplay = calloc(1, strlen(szDisplay) + strlen("DISPLAY=") + 1);
|
||||
if (szEnvDisplay) {
|
||||
snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
|
||||
putenv(szEnvDisplay);
|
||||
|
|
|
@ -42,8 +42,7 @@ extern void ErrorF (const char* /*f*/, ...);
|
|||
/* Copy the parsed string, must be free()d in yacc parser */
|
||||
static char *makestr(char *str)
|
||||
{
|
||||
char *ptr;
|
||||
ptr = malloc(strlen(str)+1);
|
||||
char *ptr = calloc(1, strlen(str)+1);
|
||||
if (!ptr)
|
||||
{
|
||||
ErrorF ("winMultiWindowLex:makestr() out of memory\n");
|
||||
|
|
|
@ -310,7 +310,7 @@ static void
|
|||
AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
|
||||
{
|
||||
if (menu.menuItem==NULL)
|
||||
menu.menuItem = malloc(sizeof(MENUITEM));
|
||||
menu.menuItem = calloc(1, sizeof(MENUITEM));
|
||||
else
|
||||
menu.menuItem = realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
|
||||
|
||||
|
@ -339,7 +339,7 @@ CloseMenu (void)
|
|||
if (pref.menuItems)
|
||||
pref.menu = realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
|
||||
else
|
||||
pref.menu = malloc (sizeof(MENUPARSED));
|
||||
pref.menu = calloc(1, sizeof(MENUPARSED));
|
||||
|
||||
memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
|
||||
pref.menuItems++;
|
||||
|
@ -362,7 +362,7 @@ static void
|
|||
AddIconLine (char *matchstr, char *iconfile)
|
||||
{
|
||||
if (pref.icon==NULL)
|
||||
pref.icon = malloc(sizeof(ICONITEM));
|
||||
pref.icon = calloc(1, sizeof(ICONITEM));
|
||||
else
|
||||
pref.icon = realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
|
||||
|
||||
|
@ -397,7 +397,7 @@ static void
|
|||
AddStyleLine (char *matchstr, unsigned long style)
|
||||
{
|
||||
if (pref.style==NULL)
|
||||
pref.style = malloc(sizeof(STYLEITEM));
|
||||
pref.style = calloc(1, sizeof(STYLEITEM));
|
||||
else
|
||||
pref.style = realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
|
||||
|
||||
|
@ -429,7 +429,7 @@ static void
|
|||
AddSysMenuLine (char *matchstr, char *menuname, int pos)
|
||||
{
|
||||
if (pref.sysMenu==NULL)
|
||||
pref.sysMenu = malloc(sizeof(SYSMENUITEM));
|
||||
pref.sysMenu = calloc(1, sizeof(SYSMENUITEM));
|
||||
else
|
||||
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 */
|
||||
g_pszCommandLine = malloc(iSize + 1);
|
||||
g_pszCommandLine = calloc(1, iSize + 1);
|
||||
if (!g_pszCommandLine)
|
||||
FatalError("winLogCommandLine - Could not allocate memory for "
|
||||
"command line string. Exiting.\n");
|
||||
|
|
|
@ -266,14 +266,14 @@ winRandRInit(ScreenPtr pScreen)
|
|||
output->crtc = crtc;
|
||||
|
||||
/* Set crtc outputs (should use RRCrtcNotify?) */
|
||||
crtc->outputs = malloc(sizeof(RROutputPtr));
|
||||
crtc->outputs = calloc(1, sizeof(RROutputPtr));
|
||||
crtc->outputs[0] = output;
|
||||
crtc->numOutputs = 1;
|
||||
|
||||
pRRScrPriv->primaryOutput = output;
|
||||
|
||||
/* Ensure we have space for exactly one mode */
|
||||
output->modes = malloc(sizeof(RRModePtr));
|
||||
output->modes = calloc(1, sizeof(RRModePtr));
|
||||
output->modes[0] = NULL;
|
||||
|
||||
/* Set mode to current display size */
|
||||
|
|
|
@ -151,7 +151,6 @@ static
|
|||
winQueryRGBBitsAndMasks(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
BITMAPINFOHEADER *pbmih = NULL;
|
||||
Bool fReturn = TRUE;
|
||||
LPDWORD pdw = NULL;
|
||||
DWORD dwRedBits, dwGreenBits, dwBlueBits;
|
||||
|
@ -187,9 +186,9 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
|
|||
}
|
||||
|
||||
/* 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) {
|
||||
ErrorF("winQueryRGBBitsAndMasks - malloc failed\n");
|
||||
ErrorF("winQueryRGBBitsAndMasks - calloc failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -541,9 +540,9 @@ winInitScreenShadowGDI(ScreenPtr pScreen)
|
|||
pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen);
|
||||
|
||||
/* 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) {
|
||||
ErrorF("winInitScreenShadowGDI - malloc () failed\n");
|
||||
ErrorF("winInitScreenShadowGDI - calloc () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue