summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2011-03-12 17:45:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2011-03-12 17:45:37 (GMT)
commite0b895874d5fa39f6d4134b407e930b80ee3ecd7 (patch)
tree08a6b50f74f697e9ebc1f689f06d7318c0aa83a2 /win
parent77d7867fd5b20233f0fa9163bd8a44d2ac274b0e (diff)
downloadtk-e0b895874d5fa39f6d4134b407e930b80ee3ecd7.zip
tk-e0b895874d5fa39f6d4134b407e930b80ee3ecd7.tar.gz
tk-e0b895874d5fa39f6d4134b407e930b80ee3ecd7.tar.bz2
Remove casts from uses of ckalloc/ckfree/... now that Tcl declares them to be
using useful casts internally.
Diffstat (limited to 'win')
-rw-r--r--win/tkWin3d.c2
-rw-r--r--win/tkWinButton.c4
-rw-r--r--win/tkWinClipboard.c2
-rw-r--r--win/tkWinColor.c13
-rw-r--r--win/tkWinCursor.c15
-rw-r--r--win/tkWinDialog.c16
-rw-r--r--win/tkWinDraw.c10
-rw-r--r--win/tkWinEmbed.c12
-rw-r--r--win/tkWinFont.c29
-rw-r--r--win/tkWinImage.c59
-rw-r--r--win/tkWinInit.c2
-rw-r--r--win/tkWinKey.c23
-rw-r--r--win/tkWinMenu.c10
-rw-r--r--win/tkWinPixmap.c6
-rw-r--r--win/tkWinScrlbr.c2
-rw-r--r--win/tkWinSend.c4
-rw-r--r--win/tkWinWindow.c4
-rw-r--r--win/tkWinWm.c127
-rw-r--r--win/tkWinX.c26
-rw-r--r--win/ttkWinTheme.c2
-rw-r--r--win/ttkWinXPTheme.c27
-rw-r--r--win/winMain.c4
22 files changed, 195 insertions, 204 deletions
diff --git a/win/tkWin3d.c b/win/tkWin3d.c
index 78f5146..fcc367d 100644
--- a/win/tkWin3d.c
+++ b/win/tkWin3d.c
@@ -45,7 +45,7 @@ typedef struct {
TkBorder *
TkpGetBorder(void)
{
- WinBorder *borderPtr = (WinBorder *) ckalloc(sizeof(WinBorder));
+ WinBorder *borderPtr = ckalloc(sizeof(WinBorder));
borderPtr->light2ColorPtr = NULL;
borderPtr->dark2ColorPtr = NULL;
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index 4fabf5b..b18a28b 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -150,7 +150,7 @@ InitBoxes(void)
&& !(tsdPtr->boxesPtr->biHeight % 2)) {
size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount)
* sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage;
- newBitmap = (LPBITMAPINFOHEADER) ckalloc(size);
+ newBitmap = ckalloc(size);
memcpy(newBitmap, tsdPtr->boxesPtr, size);
tsdPtr->boxesPtr = newBitmap;
tsdPtr->boxWidth = tsdPtr->boxesPtr->biWidth / 4;
@@ -213,7 +213,7 @@ TkpCreateButton(
{
WinButton *butPtr;
- butPtr = (WinButton *)ckalloc(sizeof(WinButton));
+ butPtr = ckalloc(sizeof(WinButton));
butPtr->hwnd = NULL;
return (TkButton *) butPtr;
}
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 120df4e..214a069 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -275,7 +275,7 @@ TkWinClipboardRender(
* Copy the data and change EOL characters.
*/
- buffer = rawText = ckalloc((unsigned)length + 1);
+ buffer = rawText = ckalloc(length + 1);
if (targetPtr != NULL) {
for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
cbPtr = cbPtr->nextPtr) {
diff --git a/win/tkWinColor.c b/win/tkWinColor.c
index c559d87..d0d4836 100644
--- a/win/tkWinColor.c
+++ b/win/tkWinColor.c
@@ -184,7 +184,7 @@ TkpGetColor(
&& FindSystemColor(name+6, &color, &index))
|| XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), name,
&color)) {
- winColPtr = (WinColor *) ckalloc(sizeof(WinColor));
+ winColPtr = ckalloc(sizeof(WinColor));
winColPtr->info.color = color;
winColPtr->index = index;
@@ -222,7 +222,7 @@ TkpGetColorByValue(
XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
- WinColor *tkColPtr = (WinColor *) ckalloc(sizeof(WinColor));
+ WinColor *tkColPtr = ckalloc(sizeof(WinColor));
tkColPtr->info.color.red = colorPtr->red;
tkColPtr->info.color.green = colorPtr->green;
@@ -445,11 +445,10 @@ XFreeColors(
GetPaletteEntries(cmap->palette, index, 1, &entry);
if (cref == RGB(entry.peRed, entry.peGreen, entry.peBlue)) {
count = cmap->size - index;
- entries = (PALETTEENTRY *)
- ckalloc(sizeof(PALETTEENTRY) * count);
+ entries = ckalloc(sizeof(PALETTEENTRY) * count);
GetPaletteEntries(cmap->palette, index+1, count, entries);
SetPaletteEntries(cmap->palette, index, count, entries);
- ckfree((char *) entries);
+ ckfree(entries);
cmap->size--;
} else {
Tcl_Panic("Tried to free a color that isn't allocated");
@@ -505,7 +504,7 @@ XCreateColormap(
logPalettePtr->palNumEntries = GetPaletteEntries(sysPal, 0, 256,
logPalettePtr->palPalEntry);
- cmap = (TkWinColormap *) ckalloc(sizeof(TkWinColormap));
+ cmap = ckalloc(sizeof(TkWinColormap));
cmap->size = logPalettePtr->palNumEntries;
cmap->stale = 0;
cmap->palette = CreatePalette(logPalettePtr);
@@ -553,7 +552,7 @@ XFreeColormap(
Tcl_Panic("Unable to free colormap, palette is still selected");
}
Tcl_DeleteHashTable(&cmap->refCounts);
- ckfree((char *) cmap);
+ ckfree(cmap);
}
/*
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 2a44196..c53b1b2 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -116,7 +116,7 @@ TkGetCursorByName(
goto badCursorSpec;
}
- cursorPtr = (TkWinCursor *) ckalloc(sizeof(TkWinCursor));
+ cursorPtr = ckalloc(sizeof(TkWinCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursorPtr;
cursorPtr->winCursor = NULL;
cursorPtr->system = 0;
@@ -135,8 +135,8 @@ TkGetCursorByName(
if (Tcl_IsSafe(interp)) {
Tcl_AppendResult(interp, "can't get cursor from a file in",
" a safe interpreter", NULL);
- ckfree((char *) argv);
- ckfree((char *) cursorPtr);
+ ckfree(argv);
+ ckfree(cursorPtr);
return NULL;
}
cursorPtr->winCursor = LoadCursorFromFileA(&(argv[0][1]));
@@ -165,15 +165,14 @@ TkGetCursorByName(
}
if (cursorPtr->winCursor == NULL) {
- ckfree((char *) cursorPtr);
+ ckfree(cursorPtr);
badCursorSpec:
- ckfree((char *) argv);
+ ckfree(argv);
Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
return NULL;
- } else {
- ckfree((char *) argv);
- return (TkCursor *) cursorPtr;
}
+ ckfree(argv);
+ return (TkCursor *) cursorPtr;
}
/*
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index ae89962..3c70a66 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -1015,7 +1015,7 @@ OFNHookProc(
*/
if ((selsize > 1) && (dirsize > 0)) {
if (ofnData->dynFileBufferSize < buffersize) {
- buffer = (WCHAR *) ckrealloc((char *) buffer, buffersize);
+ buffer = ckrealloc(buffer, buffersize);
ofnData->dynFileBufferSize = buffersize;
ofnData->dynFileBuffer = (char *) buffer;
}
@@ -1137,7 +1137,7 @@ MakeFilter(
*/
const char *defaultFilter = "All Files (*.*)";
- p = filterStr = (char*)ckalloc(30 * sizeof(char));
+ p = filterStr = ckalloc(30);
strcpy(p, defaultFilter);
p+= strlen(defaultFilter);
@@ -1173,7 +1173,7 @@ MakeFilter(
* twice the size of the string to format the filter
*/
- filterStr = ckalloc((unsigned) len * 3);
+ filterStr = ckalloc(len * 3);
for (filterPtr = flist.filters, p = filterStr; filterPtr;
filterPtr = filterPtr->next) {
@@ -1243,7 +1243,7 @@ MakeFilter(
}
Tcl_DStringAppend(dsPtr, filterStr, (int) (p - filterStr));
- ckfree((char *) filterStr);
+ ckfree(filterStr);
TkFreeFileFilters(&flist);
return TCL_OK;
@@ -2021,11 +2021,11 @@ ApplyLogfont(Tcl_Interp *interp, Tcl_Obj *cmdObj, HDC hdc, LOGFONTA *logfontPtr)
Tcl_Obj **objv, **tmpv;
Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv);
- tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = GetFontObj(hdc, logfontPtr);
TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL);
- ckfree((char *) tmpv);
+ ckfree(tmpv);
}
/*
@@ -2482,7 +2482,7 @@ DeleteHookData(ClientData clientData, Tcl_Interp *interp)
if (hdPtr->cmdObj) {
Tcl_DecrRefCount(hdPtr->cmdObj);
}
- ckfree((char *) hdPtr);
+ ckfree(hdPtr);
}
/*
@@ -2507,7 +2507,7 @@ const TkEnsemble tkFontchooserEnsemble[] = {
int
TkInitFontchooser(Tcl_Interp *interp, ClientData clientData)
{
- HookData *hdPtr = (HookData *) ckalloc(sizeof(HookData));
+ HookData *hdPtr = ckalloc(sizeof(HookData));
memset(hdPtr, 0, sizeof(HookData));
Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr);
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 5e2c415..236d14b 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -243,9 +243,9 @@ ConvertPoints(
if (npoints > tsdPtr->nWinPoints) {
if (tsdPtr->winPoints != NULL) {
- ckfree((char *) tsdPtr->winPoints);
+ ckfree(tsdPtr->winPoints);
}
- tsdPtr->winPoints = (POINT *) ckalloc(sizeof(POINT) * npoints);
+ tsdPtr->winPoints = ckalloc(sizeof(POINT) * npoints);
if (tsdPtr->winPoints == NULL) {
tsdPtr->nWinPoints = -1;
return NULL;
@@ -552,10 +552,10 @@ TkPutImage(
usePalette = (image->bits_per_pixel < 16);
if (usePalette) {
- infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER)
+ infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD)*ncolors);
} else {
- infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER));
+ infoPtr = ckalloc(sizeof(BITMAPINFOHEADER));
}
infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -582,7 +582,7 @@ TkPutImage(
}
bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT,
image->data, infoPtr, DIB_RGB_COLORS);
- ckfree((char *) infoPtr);
+ ckfree(infoPtr);
}
if (!bitmap) {
Tcl_Panic("Fail to allocate bitmap");
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index 1156751..16f8e2c 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -71,15 +71,15 @@ void
TkWinCleanupContainerList(void)
{
Container *nextPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- for (; tsdPtr->firstContainerPtr != (Container *) NULL;
+ for (; tsdPtr->firstContainerPtr != NULL;
tsdPtr->firstContainerPtr = nextPtr) {
nextPtr = tsdPtr->firstContainerPtr->nextPtr;
- ckfree((char *) tsdPtr->firstContainerPtr);
+ ckfree(tsdPtr->firstContainerPtr);
}
- tsdPtr->firstContainerPtr = (Container *) NULL;
+ tsdPtr->firstContainerPtr = NULL;
}
/*
@@ -363,7 +363,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = (Container *) ckalloc(sizeof(Container));
+ containerPtr = ckalloc(sizeof(Container));
containerPtr->parentPtr = winPtr;
containerPtr->parentHWnd = Tk_GetHWND(Tk_WindowId(tkwin));
containerPtr->embeddedHWnd = NULL;
@@ -1097,7 +1097,7 @@ EmbedWindowDeleted(
} else {
prevPtr->nextPtr = containerPtr->nextPtr;
}
- ckfree((char *) containerPtr);
+ ckfree(containerPtr);
}
}
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index e057abe..8c00f17 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -317,7 +317,7 @@ TkpGetNativeFont(
}
tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr;
- fontPtr = (WinFont *) ckalloc(sizeof(WinFont));
+ fontPtr = ckalloc(sizeof(WinFont));
InitFont(tkwin, GetStockObject(object), 0, fontPtr);
return (TkFont *) fontPtr;
@@ -575,7 +575,7 @@ TkpGetFontFromAttributes(
hFont = GetScreenFont(faPtr, faceName,
TkFontGetPixels(tkwin, faPtr->size), 0.0);
if (tkFontPtr == NULL) {
- fontPtr = (WinFont *) ckalloc(sizeof(WinFont));
+ fontPtr = ckalloc(sizeof(WinFont));
} else {
fontPtr = (WinFont *) tkFontPtr;
ReleaseFont(fontPtr);
@@ -1655,7 +1655,7 @@ ReleaseFont(
ReleaseSubFont(&fontPtr->subFontArray[i]);
}
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
- ckfree((char *) fontPtr->subFontArray);
+ ckfree(fontPtr->subFontArray);
}
}
@@ -1779,7 +1779,7 @@ AllocFontFamily(
}
}
- familyPtr = (FontFamily *) ckalloc(sizeof(FontFamily));
+ familyPtr = ckalloc(sizeof(FontFamily));
memset(familyPtr, 0, sizeof(FontFamily));
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
@@ -1881,10 +1881,10 @@ FreeFontFamily(
}
}
if (familyPtr->startCount != NULL) {
- ckfree((char *) familyPtr->startCount);
+ ckfree(familyPtr->startCount);
}
if (familyPtr->endCount != NULL) {
- ckfree((char *) familyPtr->endCount);
+ ckfree(familyPtr->endCount);
}
if (familyPtr->encoding != TkWinGetUnicodeEncoding()) {
Tcl_FreeEncoding(familyPtr->encoding);
@@ -1902,7 +1902,7 @@ FreeFontFamily(
familyPtrPtr = &(*familyPtrPtr)->nextPtr;
}
- ckfree((char *) familyPtr);
+ ckfree(familyPtr);
}
/*
@@ -2195,7 +2195,7 @@ FontMapLoadPage(
USHORT *startCount, *endCount;
int i, j, bitOffset, end, segCount;
- subFontPtr->fontMap[row] = (char *) ckalloc(FONTMAP_BITSPERPAGE / 8);
+ subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
familyPtr = subFontPtr->familyPtr;
@@ -2426,12 +2426,11 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = (SubFont *)
- ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
+ newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
memcpy(newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
- ckfree((char *) fontPtr->subFontArray);
+ ckfree(fontPtr->subFontArray);
}
/*
@@ -2823,8 +2822,8 @@ LoadFontRanges(
segCount = subTable.segment.segCountX2 / 2;
cbData = segCount * sizeof(USHORT);
- startCount = (USHORT *) ckalloc((unsigned)cbData);
- endCount = (USHORT *) ckalloc((unsigned)cbData);
+ startCount = ckalloc(cbData);
+ endCount = ckalloc(cbData);
offset = encTable.offset + sizeof(subTable.segment);
GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
@@ -2867,8 +2866,8 @@ LoadFontRanges(
segCount = 1;
cbData = segCount * sizeof(USHORT);
- startCount = (USHORT *) ckalloc((unsigned) cbData);
- endCount = (USHORT *) ckalloc((unsigned) cbData);
+ startCount = ckalloc(cbData);
+ endCount = ckalloc(cbData);
startCount[0] = 0x0000;
endCount[0] = 0x00ff;
}
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 97ce065..01b5976 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -41,9 +41,9 @@ DestroyImage(
{
if (imagePtr) {
if (imagePtr->data) {
- ckfree((char*)imagePtr->data);
+ ckfree(imagePtr->data);
}
- ckfree((char*)imagePtr);
+ ckfree(imagePtr);
}
return 0;
}
@@ -213,7 +213,7 @@ XCreateImage(
int bitmap_pad,
int bytes_per_line)
{
- XImage* imagePtr = (XImage *) ckalloc(sizeof(XImage));
+ XImage* imagePtr = ckalloc(sizeof(XImage));
imagePtr->width = width;
imagePtr->height = height;
imagePtr->xoffset = offset;
@@ -351,7 +351,7 @@ XGetImageZPixmap(
if (depth <= 8) {
size += sizeof(unsigned short) * (1 << depth);
}
- bmInfo = (BITMAPINFO *) ckalloc((unsigned)size);
+ bmInfo = ckalloc(size);
bmInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo->bmiHeader.biWidth = width;
@@ -369,7 +369,7 @@ XGetImageZPixmap(
unsigned char *p, *pend;
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_PAL_COLORS);
- data = (unsigned char *) ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -378,7 +378,7 @@ XGetImageZPixmap(
ret_image = XCreateImage(display, NULL, depth, ZPixmap, 0, (char *) data,
width, height, 32, (int) ((width + 31) >> 3) & ~1);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -388,8 +388,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -405,7 +405,7 @@ XGetImageZPixmap(
unsigned char *p;
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_PAL_COLORS);
- data = (unsigned char *) ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -414,7 +414,7 @@ XGetImageZPixmap(
ret_image = XCreateImage(display, NULL, 8, ZPixmap, 0, (char *) data,
width, height, 8, (int) width);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -424,8 +424,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -436,7 +436,7 @@ XGetImageZPixmap(
}
} else if (depth == 16) {
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS);
- data = (unsigned char *) ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -445,7 +445,7 @@ XGetImageZPixmap(
ret_image = XCreateImage(display, NULL, 16, ZPixmap, 0, (char *) data,
width, height, 16, 0 /* will be calc'ed from bitmap_pad */);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -455,14 +455,14 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
} else {
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS);
- data = (unsigned char *) ckalloc(width * height * 4);
+ data = ckalloc(width * height * 4);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -471,7 +471,7 @@ XGetImageZPixmap(
ret_image = XCreateImage(display, NULL, 32, ZPixmap, 0, (char *) data,
width, height, 0, (int) width * 4);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -485,10 +485,10 @@ XGetImageZPixmap(
unsigned int byte_width, h, w;
byte_width = ((width * 3 + 3) & ~(unsigned)3);
- smallBitBase = (unsigned char *) ckalloc(byte_width * height);
+ smallBitBase = ckalloc(byte_width * height);
if (!smallBitBase) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -500,9 +500,9 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, smallBitData, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
- ckfree((char *) smallBitBase);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
+ ckfree(smallBitBase);
ret_image = NULL;
goto cleanup;
}
@@ -527,7 +527,7 @@ XGetImageZPixmap(
* Free the Device contexts, and the Bitmap.
*/
- ckfree((char *) smallBitBase);
+ ckfree(smallBitBase);
} else {
/*
* Get the BITMAP info directly into the Image.
@@ -535,8 +535,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -545,7 +545,7 @@ XGetImageZPixmap(
cleanup:
if (bmInfo) {
- ckfree((char *) bmInfo);
+ ckfree(bmInfo);
}
if (hPal) {
SelectPalette(hdcMem, hPalPrev1, FALSE);
@@ -662,8 +662,7 @@ XGetImage(
imagePtr = XCreateImage(display, NULL, 1, XYBitmap, 0, NULL,
width, height, 32, 0);
- imagePtr->data =
- ckalloc((unsigned) imagePtr->bytes_per_line*imagePtr->height);
+ imagePtr->data = ckalloc(imagePtr->bytes_per_line * imagePtr->height);
dc = GetDC(NULL);
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index 128cfa9..09a0a71 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -92,7 +92,7 @@ TkpGetAppName(
}
Tcl_DStringAppend(namePtr, name, namelength);
if (argv != NULL) {
- ckfree((char *)argv);
+ ckfree(argv);
}
}
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index b537114..f8fce5e 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -504,12 +504,11 @@ TkpInitKeymapInfo(
*/
if (dispPtr->modKeyCodes != NULL) {
- ckfree((char *) dispPtr->modKeyCodes);
+ ckfree(dispPtr->modKeyCodes);
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = (KeyCode *) ckalloc((unsigned)
- (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
+ dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -532,11 +531,10 @@ TkpInitKeymapInfo(
*/
arraySize *= 2;
- new = (KeyCode *) ckalloc((unsigned)
- (arraySize * sizeof(KeyCode)));
- memcpy((void *) new, (void *) dispPtr->modKeyCodes,
- (dispPtr->numModKeyCodes * sizeof(KeyCode)));
- ckfree((char *) dispPtr->modKeyCodes);
+ new = ckalloc(arraySize * sizeof(KeyCode));
+ memcpy(new, dispPtr->modKeyCodes,
+ dispPtr->numModKeyCodes * sizeof(KeyCode));
+ ckfree(dispPtr->modKeyCodes);
dispPtr->modKeyCodes = new;
}
dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
@@ -662,11 +660,10 @@ XModifierKeymap *
XGetModifierMapping(
Display *display)
{
- XModifierKeymap *map = (XModifierKeymap *)
- ckalloc(sizeof(XModifierKeymap));
+ XModifierKeymap *map = ckalloc(sizeof(XModifierKeymap));
map->max_keypermod = 1;
- map->modifiermap = (KeyCode *) ckalloc(sizeof(KeyCode)*8);
+ map->modifiermap = ckalloc(sizeof(KeyCode) * 8);
map->modifiermap[ShiftMapIndex] = VK_SHIFT;
map->modifiermap[LockMapIndex] = VK_CAPITAL;
map->modifiermap[ControlMapIndex] = VK_CONTROL;
@@ -698,8 +695,8 @@ void
XFreeModifiermap(
XModifierKeymap *modmap)
{
- ckfree((char *) modmap->modifiermap);
- ckfree((char *) modmap);
+ ckfree(modmap->modifiermap);
+ ckfree(modmap);
}
/*
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 4347cfd..2ced640 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -517,7 +517,7 @@ GetEntryText(
}
}
- itemText = ckalloc((unsigned)Tcl_DStringLength(&itemString) + 1);
+ itemText = ckalloc(Tcl_DStringLength(&itemString) + 1);
strcpy(itemText, Tcl_DStringValue(&itemString));
Tcl_DStringFree(&itemString);
}
@@ -710,8 +710,8 @@ ReconfigureWindowsMenu(
if ((menuPtr->menuType == MENUBAR)
&& (menuPtr->parentTopLevelPtr != NULL)) {
- HANDLE bar;
- bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
+ HANDLE bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
+
if (bar) {
DrawMenuBar(bar);
}
@@ -1209,7 +1209,7 @@ TkWinHandleMenuEvent(
}
mePtr = (TkMenuEntry *) itemPtr->itemData;
menuPtr = mePtr->menuPtr;
- twdPtr = (TkWinDrawable *) ckalloc(sizeof(TkWinDrawable));
+ twdPtr = ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDC;
twdPtr->winDC.hdc = itemPtr->hDC;
@@ -1252,7 +1252,7 @@ TkWinHandleMenuEvent(
itemPtr->rcItem.bottom - itemPtr->rcItem.top,
0, drawingParameters);
- ckfree((char *) twdPtr);
+ ckfree(twdPtr);
}
*plResult = 1;
returnResult = 1;
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index 3827b3b..05d1ba1 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -44,7 +44,7 @@ Tk_GetPixmap(
display->request++;
- newTwdPtr = (TkWinDrawable *) ckalloc(sizeof(TkWinDrawable));
+ newTwdPtr = ckalloc(sizeof(TkWinDrawable));
newTwdPtr->type = TWD_BITMAP;
newTwdPtr->bitmap.depth = depth;
twdPtr = (TkWinDrawable *) d;
@@ -116,7 +116,7 @@ Tk_GetPixmap(
}
if (newTwdPtr->bitmap.handle == NULL) {
- ckfree((char *) newTwdPtr);
+ ckfree(newTwdPtr);
return None;
}
@@ -149,7 +149,7 @@ Tk_FreePixmap(
display->request++;
if (twdPtr != NULL) {
DeleteObject(twdPtr->bitmap.handle);
- ckfree((char *) twdPtr);
+ ckfree(twdPtr);
}
}
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 87edb75..fed516e 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -123,7 +123,7 @@ TkpCreateScrollbar(
Tcl_MutexUnlock(&winScrlbrMutex);
}
- scrollPtr = (WinScrollbar *) ckalloc(sizeof(WinScrollbar));
+ scrollPtr = ckalloc(sizeof(WinScrollbar));
scrollPtr->winFlags = 0;
scrollPtr->hwnd = NULL;
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index 9010884..e191609 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -167,7 +167,7 @@ Tk_SetAppName(
if (riPtr == NULL) {
LPUNKNOWN *objPtr;
- riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp));
+ riPtr = ckalloc(sizeof(RegisteredInterp));
memset(riPtr, 0, sizeof(RegisteredInterp));
riPtr->interp = interp;
@@ -953,7 +953,7 @@ TkWinSend_QueueCommand(
TRACE("SendQueueCommand()\n");
- evPtr = (SendEvent *)ckalloc(sizeof(SendEvent));
+ evPtr = ckalloc(sizeof(SendEvent));
evPtr->header.proc = SendEventProc;
evPtr->header.nextPtr = NULL;
evPtr->interp = interp;
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c
index e1ce602..898e38b 100644
--- a/win/tkWinWindow.c
+++ b/win/tkWinWindow.c
@@ -68,7 +68,7 @@ Tk_AttachHWND(
*/
if (twdPtr == NULL) {
- twdPtr = (TkWinDrawable *) ckalloc(sizeof(TkWinDrawable));
+ twdPtr = ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDOW;
twdPtr->window.winPtr = (TkWindow *) tkwin;
} else if (twdPtr->window.handle != NULL) {
@@ -330,7 +330,7 @@ XDestroyWindow(
Tcl_DeleteHashEntry(entryPtr);
}
- ckfree((char *)twdPtr);
+ ckfree(twdPtr);
/*
* Don't bother destroying the window if we are going to destroy the
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 6b151cb..86f9dad 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -1262,7 +1262,7 @@ ReadIconFromFile(
size = sizeof(BlockOfIconImages)
+ ((res != 0) ? sizeof(ICONIMAGE) : 0);
- lpIR = (BlockOfIconImagesPtr) ckalloc(size);
+ lpIR = ckalloc(size);
if (lpIR == NULL) {
if (res != 0) {
DestroyIcon(sfi.hIcon);
@@ -1293,7 +1293,7 @@ ReadIconFromFile(
Tcl_DStringFree(&ds2);
}
if (lpIR != NULL) {
- titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance));
+ titlebaricon = ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
}
@@ -1369,7 +1369,7 @@ GetIconFromPixmap(
return NULL;
}
- lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages));
+ lpIR = ckalloc(sizeof(BlockOfIconImages));
if (lpIR == NULL) {
DestroyIcon(hIcon);
return NULL;
@@ -1390,7 +1390,7 @@ GetIconFromPixmap(
lpIR->IconImages[0].lpXOR = 0;
lpIR->IconImages[0].lpAND = 0;
- titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance));
+ titlebaricon = ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
return titlebaricon;
@@ -1426,7 +1426,7 @@ DecrIconRefCount(
}
titlebaricon->iconBlock = NULL;
- ckfree((char *) titlebaricon);
+ ckfree(titlebaricon);
}
}
@@ -1459,13 +1459,13 @@ FreeIconBlock(
for (i=0 ; i<lpIR->nNumImages ; i++) {
if (lpIR->IconImages[i].lpBits != NULL) {
- ckfree((char *) lpIR->IconImages[i].lpBits);
+ ckfree(lpIR->IconImages[i].lpBits);
}
if (lpIR->IconImages[i].hIcon != NULL) {
DestroyIcon(lpIR->IconImages[i].hIcon);
}
}
- ckfree((char *) lpIR);
+ ckfree(lpIR);
}
/*
@@ -1596,7 +1596,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource structure
*/
- lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages));
+ lpIR = ckalloc(sizeof(BlockOfIconImages));
/*
* Read in the header
@@ -1606,7 +1606,7 @@ ReadIconOrCursorFromFile(
if (lpIR->nNumImages == -1) {
Tcl_AppendResult(interp, "Invalid file header", NULL);
Tcl_Close(NULL, channel);
- ckfree((char *) lpIR);
+ ckfree(lpIR);
return NULL;
}
@@ -1614,15 +1614,14 @@ ReadIconOrCursorFromFile(
* Adjust the size of the struct to account for the images.
*/
- lpIR = (BlockOfIconImagesPtr) ckrealloc((char *) lpIR,
- sizeof(BlockOfIconImages)
+ lpIR = ckrealloc(lpIR, sizeof(BlockOfIconImages)
+ (lpIR->nNumImages - 1) * sizeof(ICONIMAGE));
/*
* Allocate enough memory for the icon directory entries.
*/
- lpIDE = (LPICONDIRENTRY) ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
+ lpIDE = ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
/*
* Read in the icon directory entries.
@@ -1633,8 +1632,8 @@ ReadIconOrCursorFromFile(
if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) {
Tcl_AppendResult(interp, "Error reading file", NULL);
Tcl_Close(NULL, channel);
- ckfree((char *) lpIDE);
- ckfree((char *) lpIR);
+ ckfree(lpIDE);
+ ckfree(lpIR);
return NULL;
}
@@ -1655,7 +1654,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource.
*/
- lpIR->IconImages[i].lpBits = (LPBYTE) ckalloc(lpIDE[i].dwBytesInRes);
+ lpIR->IconImages[i].lpBits = ckalloc(lpIDE[i].dwBytesInRes);
lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes;
/*
@@ -1682,20 +1681,20 @@ ReadIconOrCursorFromFile(
* Set the internal pointers appropriately.
*/
- if (!AdjustIconImagePointers( &(lpIR->IconImages[i]))) {
+ if (!AdjustIconImagePointers(&lpIR->IconImages[i])) {
Tcl_AppendResult(interp, "Error converting to internal format",
NULL);
goto readError;
}
lpIR->IconImages[i].hIcon =
- MakeIconOrCursorFromResource(&(lpIR->IconImages[i]), isIcon);
+ MakeIconOrCursorFromResource(&lpIR->IconImages[i], isIcon);
}
/*
* Clean up
*/
- ckfree((char *) lpIDE);
+ ckfree(lpIDE);
Tcl_Close(NULL, channel);
if (lpIR == NULL) {
Tcl_AppendResult(interp, "Reading of ", Tcl_GetString(fileName),
@@ -1708,11 +1707,11 @@ ReadIconOrCursorFromFile(
Tcl_Close(NULL, channel);
for (i = 0; i < lpIR->nNumImages; i++) {
if (lpIR->IconImages[i].lpBits != NULL) {
- ckfree((char *) lpIR->IconImages[i].lpBits);
+ ckfree(lpIR->IconImages[i].lpBits);
}
}
- ckfree((char *) lpIDE);
- ckfree((char *) lpIR);
+ ckfree(lpIDE);
+ ckfree(lpIR);
return NULL;
}
@@ -1909,7 +1908,7 @@ void
TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
- register WmInfo *wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));
+ register WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
/*
* Initialize full structure, then set what isn't NULL
@@ -2212,8 +2211,7 @@ UpdateWrapper(
WmInfo *wmPtr2;
- childStateInfo = (int *)
- ckalloc((unsigned) wmPtr->numTransients * sizeof(int));
+ childStateInfo = ckalloc(wmPtr->numTransients * sizeof(int));
state = 0;
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
wmPtr2 = wmPtr2->nextPtr) {
@@ -2312,7 +2310,7 @@ UpdateWrapper(
}
}
- ckfree((char *) childStateInfo);
+ ckfree(childStateInfo);
}
/*
@@ -2664,10 +2662,10 @@ TkWmDeadWindow(
Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
}
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
}
if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
+ ckfree(wmPtr->clientMachine);
}
if (wmPtr->flags & WM_UPDATE_PENDING) {
Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
@@ -2717,7 +2715,7 @@ TkWmDeadWindow(
DecrIconRefCount(wmPtr->iconPtr);
}
- ckfree((char *) wmPtr);
+ ckfree(wmPtr);
winPtr->wmInfoPtr = NULL;
}
@@ -3336,7 +3334,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc((unsigned) length + 1);
+ wmPtr->clientMachine = ckalloc(length + 1);
memcpy(wmPtr->clientMachine, argv3, (unsigned) length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -3401,13 +3399,12 @@ WmColormapwindowsCmd(
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = (TkWindow **)
- ckalloc((unsigned) (windowObjc + 1) * sizeof(TkWindow*));
+ cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*));
gotToplevel = 0;
for (i = 0; i < windowObjc; i++) {
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
(Tk_Window *) winPtr2Ptr) != TCL_OK) {
- ckfree((char *) cmapList);
+ ckfree(cmapList);
return TCL_ERROR;
}
if (winPtr2 == winPtr) {
@@ -3427,7 +3424,7 @@ WmColormapwindowsCmd(
}
wmPtr->flags |= WM_COLORMAPS_EXPLICIT;
if (wmPtr->cmapList != NULL) {
- ckfree((char *) wmPtr->cmapList);
+ ckfree(wmPtr->cmapList);
}
wmPtr->cmapList = cmapList;
wmPtr->cmapCount = windowObjc;
@@ -3488,7 +3485,7 @@ WmCommandCmd(
argv3 = Tcl_GetString(objv[3]);
if (argv3[0] == 0) {
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
wmPtr->cmdArgv = NULL;
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XDeleteProperty(winPtr->display, winPtr->window,
@@ -3501,7 +3498,7 @@ WmCommandCmd(
return TCL_ERROR;
}
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
}
wmPtr->cmdArgc = cmdArgc;
wmPtr->cmdArgv = cmdArgv;
@@ -3912,7 +3909,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(tkwin2);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc((unsigned) length + 1);
+ wmPtr->leaderName = ckalloc(length + 1);
memcpy(wmPtr->leaderName, argv3, (unsigned) length + 1);
}
return TCL_OK;
@@ -4206,10 +4203,10 @@ WmIconnameCmd(
return TCL_OK;
} else {
if (wmPtr->iconName != NULL) {
- ckfree((char *) wmPtr->iconName);
+ ckfree(wmPtr->iconName);
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->iconName = ckalloc((unsigned) length + 1);
+ wmPtr->iconName = ckalloc(length + 1);
memcpy(wmPtr->iconName, argv3, (unsigned) length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
@@ -4290,7 +4287,7 @@ WmIconphotoCmd(
*/
size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1));
- lpIR = (BlockOfIconImagesPtr) attemptckalloc(size);
+ lpIR = attemptckalloc(size);
if (lpIR == NULL) {
return TCL_ERROR;
}
@@ -4310,7 +4307,7 @@ WmIconphotoCmd(
* converts them as required. Initialise icon info structure.
*/
- ZeroMemory( &iconInfo, sizeof iconInfo );
+ ZeroMemory(&iconInfo, sizeof(iconInfo));
iconInfo.fIcon = TRUE;
/*
@@ -4325,10 +4322,10 @@ WmIconphotoCmd(
bmInfo.bmiHeader.biBitCount = 32;
bmInfo.bmiHeader.biCompression = BI_RGB;
- iconInfo.hbmColor = CreateDIBSection( NULL, &bmInfo,
- DIB_RGB_COLORS, &bgraPixel.voidPtr, NULL, 0 );
- if ( !iconInfo.hbmColor ) {
- ckfree((char *) lpIR);
+ iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
+ &bgraPixel.voidPtr, NULL, 0);
+ if (!iconInfo.hbmColor) {
+ ckfree(lpIR);
Tcl_AppendResult(interp, "failed to create color bitmap for \"",
Tcl_GetString(objv[i]), "\"", NULL);
return TCL_ERROR;
@@ -4337,6 +4334,7 @@ WmIconphotoCmd(
/*
* Convert the photo image data into BGRA format (RGBQUAD).
*/
+
bufferSize = height * width * 4;
for (idx = 0 ; idx < bufferSize ; idx += 4) {
bgraPixel.ptr[idx] = block.pixelPtr[idx+2];
@@ -4350,24 +4348,26 @@ WmIconphotoCmd(
* matter, as CreateIconIndirect will setup the icon mask based on the
* alpha channel in our color bitmap.
*/
+
bmInfo.bmiHeader.biBitCount = 1;
- iconInfo.hbmMask = CreateDIBSection( NULL, &bmInfo,
- DIB_RGB_COLORS, &bgraMask.voidPtr, NULL, 0 );
- if ( !iconInfo.hbmMask ) {
+ iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
+ &bgraMask.voidPtr, NULL, 0);
+ if (!iconInfo.hbmMask) {
DeleteObject(iconInfo.hbmColor);
- ckfree((char *) lpIR);
+ ckfree(lpIR);
Tcl_AppendResult(interp, "failed to create mask bitmap for \"",
Tcl_GetString(objv[i]), "\"", NULL);
return TCL_ERROR;
}
- ZeroMemory( bgraMask.ptr, width*height/8 );
+ ZeroMemory(bgraMask.ptr, width*height/8);
/*
* Create an icon from the bitmaps.
*/
- hIcon = CreateIconIndirect( &iconInfo);
+
+ hIcon = CreateIconIndirect(&iconInfo);
DeleteObject(iconInfo.hbmColor);
DeleteObject(iconInfo.hbmMask);
if (hIcon == NULL) {
@@ -4375,7 +4375,7 @@ WmIconphotoCmd(
* XXX should free up created icons.
*/
- ckfree((char *) lpIR);
+ ckfree(lpIR);
Tcl_AppendResult(interp, "failed to create icon for \"",
Tcl_GetString(objv[i]), "\"", NULL);
return TCL_ERROR;
@@ -4386,7 +4386,7 @@ WmIconphotoCmd(
lpIR->IconImages[i-startObj].hIcon = hIcon;
}
- titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance));
+ titlebaricon = ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) {
@@ -4925,7 +4925,7 @@ WmProtocolCmd(
}
cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = (ProtocolHandler *) ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = ckalloc(HANDLER_SIZE(cmdLength));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
@@ -5108,7 +5108,7 @@ WmStackorderCmd(
for (window_ptr = windows; *window_ptr ; window_ptr++) {
Tcl_AppendElement(interp, (*window_ptr)->pathName);
}
- ckfree((char *) windows);
+ ckfree(windows);
return TCL_OK;
} else {
TkWindow *winPtr2, **winPtr2Ptr = &winPtr2;
@@ -5163,7 +5163,7 @@ WmStackorderCmd(
Tcl_Panic("winPtr2 window not found");
}
- ckfree((char *) windows);
+ ckfree(windows);
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
&index) != TCL_OK) {
@@ -5381,7 +5381,7 @@ WmTitleCmd(
ckfree(wmPtr->title);
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->title = ckalloc((unsigned) length + 1);
+ wmPtr->title = ckalloc(length + 1);
memcpy(wmPtr->title, argv3, (unsigned) length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) {
@@ -6675,8 +6675,7 @@ TkWmStackorderToplevel(
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
- windows = (TkWindow **)
- ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
/*
* Special cases: If zero or one toplevels were mapped there is no need to
@@ -6706,7 +6705,7 @@ TkWmStackorderToplevel(
if (EnumWindows((WNDENUMPROC) TkWmStackorderToplevelEnumProc,
(LPARAM) &pair) == 0) {
- ckfree((char *) windows);
+ ckfree(windows);
windows = NULL;
} else if (pair.window_ptr != (windows-1)) {
Tcl_Panic("num matched toplevel windows does not equal num children");
@@ -6854,7 +6853,7 @@ TkWmAddToColormapWindows(
* Automatically add the toplevel itself as the last element of the list.
*/
- newPtr = (TkWindow **) ckalloc((unsigned) (count+2) * sizeof(TkWindow *));
+ newPtr = ckalloc((count+2) * sizeof(TkWindow *));
if (count > 0) {
memcpy(newPtr, oldPtr, count * sizeof(TkWindow*));
}
@@ -6864,7 +6863,7 @@ TkWmAddToColormapWindows(
newPtr[count-1] = winPtr;
newPtr[count] = topPtr;
if (oldPtr != NULL) {
- ckfree((char *) oldPtr);
+ ckfree(oldPtr);
}
topPtr->wmInfoPtr->cmapList = newPtr;
@@ -7778,7 +7777,7 @@ WmProc(
break;
case WM_ACTIVATE:
- if ( WA_ACTIVE == LOWORD(wParam) ) {
+ if (WA_ACTIVE == LOWORD(wParam)) {
winPtr = GetTopLevel(hwnd);
if (winPtr && (TkGrabState(winPtr) == TK_GRAB_EXCLUDED)) {
/*
@@ -8143,8 +8142,8 @@ TkpGetWrapperWindow(
static void
GenerateActivateEvent(TkWindow * winPtr, const int *flagPtr)
{
- ActivateEvent *eventPtr;
- eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
+ ActivateEvent *eventPtr = ckalloc(sizeof(ActivateEvent));
+
eventPtr->ev.proc = ActivateWindow;
eventPtr->winPtr = winPtr;
eventPtr->flagPtr = flagPtr;
diff --git a/win/tkWinX.c b/win/tkWinX.c
index a02e442..10431ed 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -490,9 +490,9 @@ TkWinDisplayChanged(
screen->root_depth = GetDeviceCaps(dc, BITSPIXEL) * (int) screen->ext_data;
if (screen->root_visual != NULL) {
- ckfree((char *) screen->root_visual);
+ ckfree(screen->root_visual);
}
- screen->root_visual = (Visual *) ckalloc(sizeof(Visual));
+ screen->root_visual = ckalloc(sizeof(Visual));
screen->root_visual->visualid = 0;
if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
screen->root_visual->map_entries = GetDeviceCaps(dc, SIZEPALETTE);
@@ -559,7 +559,7 @@ TkpOpenDisplay(
Screen *screen;
TkWinDrawable *twdPtr;
Display *display;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->winDisplay != NULL) {
@@ -570,10 +570,10 @@ TkpOpenDisplay(
}
}
- display = (Display *) ckalloc(sizeof(Display));
+ display = ckalloc(sizeof(Display));
ZeroMemory(display, sizeof(Display));
- display->display_name = (char *) ckalloc(strlen(display_name)+1);
+ display->display_name = ckalloc(strlen(display_name) + 1);
strcpy(display->display_name, display_name);
display->cursor_font = 1;
@@ -581,7 +581,7 @@ TkpOpenDisplay(
display->request = 1;
display->qlen = 0;
- screen = (Screen *) ckalloc(sizeof(Screen));
+ screen = ckalloc(sizeof(Screen));
ZeroMemory(screen, sizeof(Screen));
screen->display = display;
@@ -589,7 +589,7 @@ TkpOpenDisplay(
* Set up the root window.
*/
- twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
+ twdPtr = ckalloc(sizeof(TkWinDrawable));
if (twdPtr == NULL) {
return None;
}
@@ -612,7 +612,7 @@ TkpOpenDisplay(
TkWinDisplayChanged(display);
- tsdPtr->winDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay));
+ tsdPtr->winDisplay = ckalloc(sizeof(TkDisplay));
ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay));
tsdPtr->winDisplay->display = display;
tsdPtr->updatingClipboard = FALSE;
@@ -657,17 +657,17 @@ TkpCloseDisplay(
}
if (display->screens != NULL) {
if (display->screens->root_visual != NULL) {
- ckfree((char *) display->screens->root_visual);
+ ckfree(display->screens->root_visual);
}
if (display->screens->root != None) {
- ckfree((char *) display->screens->root);
+ ckfree(display->screens->root);
}
if (display->screens->cmap != None) {
XFreeColormap(display, display->screens->cmap);
}
- ckfree((char *) display->screens);
+ ckfree(display->screens);
}
- ckfree((char *) display);
+ ckfree(display);
}
/*
@@ -1557,7 +1557,7 @@ HandleIMEComposition(
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
if (n > 0) {
- char *buff = ckalloc((unsigned) n);
+ char *buff = ckalloc(n);
TkWindow *winPtr;
XEvent event;
int i;
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c
index 022fb62..5604435 100644
--- a/win/ttkWinTheme.c
+++ b/win/ttkWinTheme.c
@@ -492,7 +492,7 @@ static void TroughClientDataDeleteProc(void *clientData)
static TroughClientData *TroughClientDataInit(Tcl_Interp *interp)
{
- TroughClientData *cd = (TroughClientData*)ckalloc(sizeof(*cd));
+ TroughClientData *cd = ckalloc(sizeof(*cd));
cd->PatternBitmap = CreateBitmap(8, 8, 1, 1, Pattern);
cd->PatternBrush = CreatePatternBrush(cd->PatternBitmap);
Ttk_RegisterCleanup(interp, cd, TroughClientDataDeleteProc);
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 1aa6393..ff97e38 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -108,7 +108,7 @@ LoadXPThemeProcs(HINSTANCE *phlib)
* We have successfully loaded the library. Proceed in storing the
* addresses of the functions we want to use.
*/
- XPThemeProcs *procs = (XPThemeProcs*)ckalloc(sizeof(XPThemeProcs));
+ XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs));
#define LOADPROC(name) \
(0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) ))
@@ -126,7 +126,7 @@ LoadXPThemeProcs(HINSTANCE *phlib)
return procs;
}
#undef LOADPROC
- ckfree((char*)procs);
+ ckfree(procs);
}
return 0;
}
@@ -411,7 +411,7 @@ typedef struct
static ElementData *
NewElementData(XPThemeProcs *procs, ElementInfo *info)
{
- ElementData *elementData = (ElementData*)ckalloc(sizeof(ElementData));
+ ElementData *elementData = ckalloc(sizeof(ElementData));
elementData->procs = procs;
elementData->info = info;
@@ -429,10 +429,10 @@ static void DestroyElementData(void *clientData)
{
ElementData *elementData = clientData;
if (elementData->info->flags & HEAP_ELEMENT) {
- ckfree((char *)elementData->info->statemap);
- ckfree((char *)elementData->info->className);
- ckfree((char *)elementData->info->elementName);
- ckfree((char *)elementData->info);
+ ckfree(elementData->info->statemap);
+ ckfree(elementData->info->className);
+ ckfree(elementData->info->elementName);
+ ckfree(elementData->info);
}
ckfree(clientData);
}
@@ -1133,8 +1133,7 @@ Ttk_CreateVsapiElement(
if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
return TCL_ERROR;
/* we over-allocate to ensure there is a terminating entry */
- stateTable = (Ttk_StateTable *)
- ckalloc(sizeof(Ttk_StateTable) * (count + 1));
+ stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1));
memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1));
for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) {
Ttk_StateSpec spec = {0,0};
@@ -1147,15 +1146,15 @@ Ttk_CreateVsapiElement(
}
}
if (status != TCL_OK) {
- ckfree((char *)stateTable);
+ ckfree(stateTable);
return status;
}
} else {
- stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable));
+ stateTable = ckalloc(sizeof(Ttk_StateTable));
memset(stateTable, 0, sizeof(Ttk_StateTable));
}
- elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo));
+ elementPtr = ckalloc(sizeof(ElementInfo));
elementPtr->elementSpec = &GenericElementSpec;
elementPtr->partId = partId;
elementPtr->statemap = stateTable;
@@ -1168,7 +1167,7 @@ Ttk_CreateVsapiElement(
elementPtr->elementName = name;
/* set the class name to an allocated copy */
- wname = (LPWSTR) ckalloc(sizeof(WCHAR) * (length + 1));
+ wname = ckalloc(sizeof(WCHAR) * (length + 1));
wcscpy(wname, className);
elementPtr->className = wname;
@@ -1215,7 +1214,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
* Set theme data and cleanup proc
*/
- themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData));
+ themeData = ckalloc(sizeof(XPThemeData));
themeData->procs = procs;
themeData->hlibrary = hlibrary;
diff --git a/win/winMain.c b/win/winMain.c
index c6591c5..badda10 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -354,8 +354,8 @@ setargv(
#undef Tcl_Alloc
#undef Tcl_DbCkalloc
- argSpace = (TCHAR *) ckalloc(
- (unsigned) (size * sizeof(char *) + (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR)));
+ argSpace = ckalloc(size*sizeof(char *)
+ + (_tcslen(cmdLine)+1) * sizeof(TCHAR));
argv = (TCHAR **) argSpace;
argSpace += size * (sizeof(char *)/sizeof(TCHAR));
size--;