diff options
150 files changed, 1244 insertions, 1345 deletions
@@ -1,3 +1,8 @@ +2011-03-12 Donal K. Fellows <dkf@users.sf.net> + + Remove casts from uses of ckalloc/ckfree/... now that Tcl declares + them to be using useful casts internally. + 2011-03-12 Jan Nijtmans <nijtmans@users.sf.net> * win/tkWin32Dll.c: Eliminate unneeded _TkFinalize wrapper. @@ -13,7 +18,7 @@ * unix/configure.in: Use a symbol from libXft itself for the link test rather than one from libfreetype, because the latter doesn't work when the linker is called with --as-needed. - + 2011-03-03 Alexandre Ferrieux <ferrieux@users.sourceforge.net> * generic/tkCanvLine.c: [Bug 3175610]: Incomplete refresh of line items. @@ -27,7 +32,7 @@ 2011-01-24 Joe English <jenglish@users.sourceforge.net> - * generic/tkSelect.c: Fix for [Bug #3164879] + * generic/tkSelect.c: Fix for [Bug #3164879]: (memory allocation bug introduced by [Patch #3129527]) 2011-01-22 Joe English <jenglish@users.sourceforge.net> diff --git a/carbon/tkMacOSXBitmap.c b/carbon/tkMacOSXBitmap.c index a5891eb..70dc9e7 100644 --- a/carbon/tkMacOSXBitmap.c +++ b/carbon/tkMacOSXBitmap.c @@ -100,10 +100,8 @@ TkpDefineNativeBitmaps(void) name = Tk_GetUid(builtInPtr->name); predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); if (isNew) { - TkPredefBitmap *predefPtr = (TkPredefBitmap *) - ckalloc(sizeof(TkPredefBitmap)); - NativeIcon *nativeIconPtr = (NativeIcon *) - ckalloc(sizeof(NativeIcon)); + TkPredefBitmap *predefPtr = ckalloc(sizeof(TkPredefBitmap)); + NativeIcon *nativeIconPtr = ckalloc(sizeof(NativeIcon)); nativeIconPtr->id = builtInPtr->id; nativeIconPtr->type = builtInPtr->type; diff --git a/carbon/tkMacOSXButton.c b/carbon/tkMacOSXButton.c index 4bd2cbe..d02c8ad 100644 --- a/carbon/tkMacOSXButton.c +++ b/carbon/tkMacOSXButton.c @@ -146,7 +146,7 @@ TkButton * TkpCreateButton( Tk_Window tkwin) { - MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); + MacButton *macButtonPtr = ckalloc(sizeof(MacButton)); Tk_CreateEventHandler(tkwin, ActivateMask, ButtonEventProc, (ClientData) macButtonPtr); diff --git a/carbon/tkMacOSXColor.c b/carbon/tkMacOSXColor.c index 3ac8207..e139038 100644 --- a/carbon/tkMacOSXColor.c +++ b/carbon/tkMacOSXColor.c @@ -594,11 +594,11 @@ TkpGetColor( } if (XParseColor(display, colormap, name, &color) == 0) { - return (TkColor *) NULL; + return NULL; } -validXColor: - tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + validXColor: + tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color = color; return tkColPtr; @@ -632,7 +632,7 @@ TkpGetColorByValue( XColor *colorPtr) /* Red, green, and blue fields indicate * desired color. */ { - TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + TkColor *tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; diff --git a/carbon/tkMacOSXCursor.c b/carbon/tkMacOSXCursor.c index 61afab5..d4d0019 100644 --- a/carbon/tkMacOSXCursor.c +++ b/carbon/tkMacOSXCursor.c @@ -198,7 +198,7 @@ TkGetCursorByName( TkMacOSXCursor *macCursorPtr; int count = -1; - macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor)); + macCursorPtr = ckalloc(sizeof(TkMacOSXCursor)); macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr; /* @@ -260,13 +260,13 @@ TkGetCursorByName( if (argc > 1) { FindCursorByName(macCursorPtr, argv[0]); } - ckfree((char *) argv); + ckfree(argv); } } } if (macCursorPtr->macCursor == NULL) { - ckfree((char *)macCursorPtr); + ckfree(macCursorPtr); Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); return NULL; } diff --git a/carbon/tkMacOSXDialog.c b/carbon/tkMacOSXDialog.c index 968daf6..3525dae 100644 --- a/carbon/tkMacOSXDialog.c +++ b/carbon/tkMacOSXDialog.c @@ -830,7 +830,7 @@ NavServicesGetFile( int index = 0; ofdPtr->curType = 0; - menuItemNames = (CFStringRef *) + menuItemNames = ckalloc(ofdPtr->fl.numFilters * sizeof(CFStringRef)); for (filterPtr = ofdPtr->fl.filters; filterPtr != NULL; @@ -1021,7 +1021,7 @@ NavServicesGetFile( for (i = 0; i < ofdPtr->fl.numFilters; i++) { CFRelease(menuItemNames[i]); } - ckfree((void *) menuItemNames); + ckfree(menuItemNames); } if (options.popupExtension) { CFRelease(options.popupExtension); @@ -1885,13 +1885,12 @@ TkMacOSXProcessFontEvent( result = Tcl_ListObjGetElements(fontchooserInterp, fcdPtr->cmdObj, &objc, &objv); if (result == TCL_OK) { - tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * - (unsigned)(objc + 2)); + tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = fontObj; result = TkBackgroundEvalObjv(fontchooserInterp, objc + 1, tmpv, TCL_EVAL_GLOBAL); - ckfree((char *)tmpv); + ckfree(tmpv); } } TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); @@ -2259,7 +2258,7 @@ DeleteFontchooserData( if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } - ckfree((char *)fcdPtr); + ckfree(fcdPtr); if (fontchooserInterp == interp) { fontchooserInterp = NULL; @@ -2288,8 +2287,7 @@ TkInitFontchooser( Tcl_Interp *interp, ClientData clientData) { - FontchooserData *fcdPtr = (FontchooserData*) - ckalloc(sizeof(FontchooserData)); + FontchooserData *fcdPtr = ckalloc(sizeof(FontchooserData)); bzero(fcdPtr, sizeof(FontchooserData)); Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteFontchooserData, diff --git a/carbon/tkMacOSXDraw.c b/carbon/tkMacOSXDraw.c index da4603c..60240d8 100644 --- a/carbon/tkMacOSXDraw.c +++ b/carbon/tkMacOSXDraw.c @@ -498,7 +498,7 @@ TkPutImage( sliceWidth = (long) image->width * maxRowBytes / rowBytes; lastSliceWidth = image->width - (sliceWidth * slices); dataPtr = image->data + image->xoffset; - newData = (char *) ckalloc(image->height * sliceRowBytes); + newData = ckalloc(image->height * sliceRowBytes); do { if (slices) { pixmap.bounds.right = pixmap.bounds.left + sliceWidth; @@ -2007,7 +2007,7 @@ TkMacOSXMakeStippleMap( GetPortBounds(TkMacOSXGetDrawablePort(drawable), &portRect); width = portRect.right - portRect.left; height = portRect.bottom - portRect.top; - bitmapPtr = (BitMap *) ckalloc(sizeof(BitMap)); + bitmapPtr = ckalloc(sizeof(BitMap)); bitmapPtr->bounds.top = bitmapPtr->bounds.left = 0; bitmapPtr->bounds.right = (short) width; bitmapPtr->bounds.bottom = (short) height; diff --git a/carbon/tkMacOSXEmbed.c b/carbon/tkMacOSXEmbed.c index 9f80401..275f61d 100644 --- a/carbon/tkMacOSXEmbed.c +++ b/carbon/tkMacOSXEmbed.c @@ -92,8 +92,7 @@ Tk_MacOSXSetEmbedHandler( Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) { if (tkMacOSXEmbedHandler == NULL) { - tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *) - ckalloc(sizeof(TkMacOSXEmbedHandler)); + tkMacOSXEmbedHandler = ckalloc(sizeof(TkMacOSXEmbedHandler)); } tkMacOSXEmbedHandler->registerWinProc = registerWinProc; tkMacOSXEmbedHandler->getPortProc = getPortProc; @@ -137,7 +136,7 @@ TkpMakeWindow( * Allocate sub window */ - macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macWin = ckalloc(sizeof(MacDrawable)); if (macWin == NULL) { winPtr->privatePtr = NULL; return None; @@ -263,7 +262,7 @@ TkpUseWindow( * Make the embedded window. */ - macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macWin = ckalloc(sizeof(MacDrawable)); if (macWin == NULL) { winPtr->privatePtr = NULL; return TCL_ERROR; @@ -319,7 +318,7 @@ TkpUseWindow( " does not correspond to a valid Tk Window.", NULL); return TCL_ERROR; } else { - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parentPtr = NULL; containerPtr->embedded = (Window) macWin; @@ -392,7 +391,7 @@ TkpMakeContainer( */ Tk_MakeWindowExist(tkwin); - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parent = Tk_WindowId(tkwin); containerPtr->parentPtr = winPtr; containerPtr->embedded = None; @@ -1117,7 +1116,7 @@ EmbedWindowDeleted( } else { prevPtr->nextPtr = containerPtr->nextPtr; } - ckfree((char *) containerPtr); + ckfree(containerPtr); } } diff --git a/carbon/tkMacOSXFont.c b/carbon/tkMacOSXFont.c index cfc1b79..3ee7551 100644 --- a/carbon/tkMacOSXFont.c +++ b/carbon/tkMacOSXFont.c @@ -474,7 +474,7 @@ TkpGetNativeFont( } CopyPascalStringToC(fontName, (char*)fontName); - fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); + fontPtr = ckalloc(sizeof(MacFont)); InitFont(fontFamily, (char*)fontName, fontSize, fontStyle, fontPtr); return (TkFont *) fontPtr; @@ -549,7 +549,7 @@ TkpGetFontFromAttributes( qdStyle |= underline; } if (tkFontPtr == NULL) { - fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); + fontPtr = ckalloc(sizeof(MacFont)); } else { fontPtr = (MacFont *) tkFontPtr; ReleaseFont(fontPtr); @@ -2328,7 +2328,7 @@ AddFontFamily( if (familyListNextFree >= familyListSize) { familyListSize += 100; - familyList = (MacFontFamily *) ckrealloc((void*) familyList, + familyList = ckrealloc(familyList, familyListSize * sizeof(*familyList)); } @@ -2442,7 +2442,7 @@ AddString( if (stringMemory == NULL || (stringMemory->nextFree+len) > STRING_BLOCK_MAX) { - StringBlock * newblock = (StringBlock *) ckalloc(sizeof(StringBlock)); + StringBlock *newblock = ckalloc(sizeof(StringBlock)); newblock->next = stringMemory; newblock->nextFree = 0; diff --git a/carbon/tkMacOSXHLEvents.c b/carbon/tkMacOSXHLEvents.c index c9ee7c7..61c9eec 100644 --- a/carbon/tkMacOSXHLEvents.c +++ b/carbon/tkMacOSXHLEvents.c @@ -172,7 +172,7 @@ QuitHandler( * quickly as possible. */ - eventPtr = (KillEvent *) ckalloc(sizeof(KillEvent)); + eventPtr = ckalloc(sizeof(KillEvent)); eventPtr->header.proc = ReallyKillMe; eventPtr->interp = interp; diff --git a/carbon/tkMacOSXKeyboard.c b/carbon/tkMacOSXKeyboard.c index d7638fd..2e40a31 100644 --- a/carbon/tkMacOSXKeyboard.c +++ b/carbon/tkMacOSXKeyboard.c @@ -372,7 +372,7 @@ XGetModifierMapping( * don't generate them either. So there is no modifier map. */ - modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap)); + modmap = ckalloc(sizeof(XModifierKeymap)); modmap->max_keypermod = 0; modmap->modifiermap = NULL; return modmap; @@ -399,9 +399,9 @@ XFreeModifiermap( XModifierKeymap *modmap) { if (modmap->modifiermap != NULL) { - ckfree((char *) modmap->modifiermap); + ckfree(modmap->modifiermap); } - ckfree((char *) modmap); + ckfree(modmap); } /* @@ -826,7 +826,7 @@ TkpInitKeymapInfo( */ if (dispPtr->modKeyCodes != NULL) { - ckfree((char *) dispPtr->modKeyCodes); + ckfree(dispPtr->modKeyCodes); } dispPtr->numModKeyCodes = 0; dispPtr->modKeyCodes = NULL; diff --git a/carbon/tkMacOSXMenu.c b/carbon/tkMacOSXMenu.c index aaf8ea9..a31daf8 100644 --- a/carbon/tkMacOSXMenu.c +++ b/carbon/tkMacOSXMenu.c @@ -702,7 +702,7 @@ TkpNewMenu( return TCL_ERROR; } - menuPtr->platformData = (TkMenuPlatformData) ckalloc(sizeof(MacMenu)); + menuPtr->platformData = ckalloc(sizeof(MacMenu)); ((MacMenu *) menuPtr->platformData)->menuHdl = macMenuHdl; #ifdef USE_TK_MDEF @@ -791,7 +791,7 @@ TkpDestroyMenu( DeleteMenu(menuID); TkMacOSXFreeMenuID(menuID); DisposeMenu(macMenuHdl); - ckfree((char *) menuPtr->platformData); + ckfree(menuPtr->platformData); menuPtr->platformData = NULL; } } @@ -853,7 +853,7 @@ TkpDestroyMenuEntry( { TkMenu *menuPtr = mePtr->menuPtr; - ckfree((char *) mePtr->platformEntryData); + ckfree(mePtr->platformEntryData); if ((menuPtr->platformData != NULL) && !(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) { menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING; @@ -1625,8 +1625,7 @@ int TkpMenuNewEntry( TkMenuEntry *mePtr) /* The menu we are adding an entry to */ { - EntryGeometry *geometryPtr = (EntryGeometry *) - ckalloc(sizeof(EntryGeometry)); + EntryGeometry *geometryPtr = ckalloc(sizeof(EntryGeometry)); TkMenu *menuPtr = mePtr->menuPtr; geometryPtr->accelTextStart = 0; @@ -1822,8 +1821,7 @@ DrawMenuBarWhenIdle( TkMacOSXGetNewMenuID(appleMenuPtr->interp, appleMenuPtr, 0, &appleID); macMenuHdl = NewMenu(appleID, "\p\024"); - appleMenuPtr->platformData = (TkMenuPlatformData) - ckalloc(sizeof(MacMenu)); + appleMenuPtr->platformData = ckalloc(sizeof(MacMenu)); ((MacMenu *)appleMenuPtr->platformData)->menuHdl = macMenuHdl; appleMenuPtr->menuFlags |= MENU_APPLE_MENU; @@ -2148,11 +2146,11 @@ TkpSetWindowMenuBar( } else { windowListPtr = listPtr->nextPtr; } - ckfree((char *) listPtr); + ckfree(listPtr); } if (menuPtr != NULL) { - listPtr = (TopLevelMenubarList *) ckalloc(sizeof(TopLevelMenubarList)); + listPtr = ckalloc(sizeof(TopLevelMenubarList)); listPtr->nextPtr = windowListPtr; windowListPtr = listPtr; listPtr->tkwin = tkwin; @@ -2265,7 +2263,6 @@ TkMacOSXDispatchMenuEvent( result = TCL_OK; } else { struct MenuCommandHandlerData *data = - (struct MenuCommandHandlerData *) ckalloc(sizeof(struct MenuCommandHandlerData)); Tcl_Preserve(menuPtr->interp); diff --git a/carbon/tkMacOSXMenubutton.c b/carbon/tkMacOSXMenubutton.c index 7891760..7e603e4 100644 --- a/carbon/tkMacOSXMenubutton.c +++ b/carbon/tkMacOSXMenubutton.c @@ -109,7 +109,7 @@ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { - MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); + MacMenuButton *mbPtr = ckalloc(sizeof(MacMenuButton)); Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, (ClientData) mbPtr); diff --git a/carbon/tkMacOSXScale.c b/carbon/tkMacOSXScale.c index 98f5397..8adcc73 100644 --- a/carbon/tkMacOSXScale.c +++ b/carbon/tkMacOSXScale.c @@ -76,7 +76,7 @@ TkScale * TkpCreateScale( Tk_Window tkwin) { - MacScale *macScalePtr = (MacScale *) ckalloc(sizeof(MacScale)); + MacScale *macScalePtr = ckalloc(sizeof(MacScale)); macScalePtr->scaleHandle = NULL; if (scaleActionProc == NULL) { diff --git a/carbon/tkMacOSXScrlbr.c b/carbon/tkMacOSXScrlbr.c index 8c83965..b6b9976 100644 --- a/carbon/tkMacOSXScrlbr.c +++ b/carbon/tkMacOSXScrlbr.c @@ -172,7 +172,7 @@ TkpCreateScrollbar( TkMacOSXInitScrollbarMetrics(); initialized = 1; } - macScrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar)); + macScrollPtr = ckalloc(sizeof(MacScrollbar)); macScrollPtr->sbHandle = NULL; macScrollPtr->macFlags = 0; SetRect(&macScrollPtr->eraseRect, 0, 0, 0, 0); diff --git a/carbon/tkMacOSXSend.c b/carbon/tkMacOSXSend.c index 642dd5c..2eb0b31 100644 --- a/carbon/tkMacOSXSend.c +++ b/carbon/tkMacOSXSend.c @@ -283,7 +283,7 @@ Tk_SetAppName( * We have found a unique name. Now add it to the registry. */ - riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp)); + riPtr = ckalloc(sizeof(RegisteredInterp)); riPtr->interp = interp; riPtr->name = ckalloc(strlen(actualName) + 1); riPtr->nextPtr = interpListPtr; diff --git a/carbon/tkMacOSXSubwindows.c b/carbon/tkMacOSXSubwindows.c index a90f171..48aef2d 100644 --- a/carbon/tkMacOSXSubwindows.c +++ b/carbon/tkMacOSXSubwindows.c @@ -105,9 +105,9 @@ XDestroyWindow( } if (macWin->toplevel->referenceCount == 0) { - ckfree((char *) macWin->toplevel); + ckfree(macWin->toplevel); } - ckfree((char *) macWin); + ckfree(macWin); return; } @@ -203,7 +203,7 @@ XDestroyWindow( } else { prevPtr->nextPtr = listPtr->nextPtr; } - ckfree((char *) listPtr); + ckfree(listPtr); break; } } @@ -218,7 +218,7 @@ XDestroyWindow( */ if (macWin->toplevel->referenceCount == 0) { - ckfree((char *) macWin->toplevel); + ckfree(macWin->toplevel); } } @@ -1410,7 +1410,7 @@ Tk_GetPixmap( if (display != NULL) { display->request++; } - macPix = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macPix = ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; @@ -1458,7 +1458,7 @@ Tk_FreePixmap( if (macPix->context) { TkMacOSXDbgMsg("Cannot free CG backed Pixmap"); } - ckfree((char *) macPix); + ckfree(macPix); } /* diff --git a/carbon/tkMacOSXWm.c b/carbon/tkMacOSXWm.c index e5707f6..6f66f8f 100644 --- a/carbon/tkMacOSXWm.c +++ b/carbon/tkMacOSXWm.c @@ -233,7 +233,7 @@ void TkWmNewWindow( TkWindow *winPtr) /* Newly-created top-level window. */ { - WmInfo *wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo)); + WmInfo *wmPtr = ckalloc(sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; @@ -491,15 +491,15 @@ 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) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } - ckfree((char *) wmPtr); + ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } @@ -1124,15 +1124,15 @@ WmClientCmd( argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); wmPtr->clientMachine = NULL; } return TCL_OK; } if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc((unsigned) length + 1); + wmPtr->clientMachine = ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } @@ -1187,12 +1187,11 @@ WmColormapwindowsCmd( != TCL_OK) { return TCL_ERROR; } - cmapList = (TkWindow **) ckalloc((unsigned) - ((windowObjc+1) * sizeof(TkWindow*))); + cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { - ckfree((char *) cmapList); + ckfree(cmapList); return TCL_ERROR; } if (winPtr2 == winPtr) { @@ -1212,7 +1211,7 @@ WmColormapwindowsCmd( } wmPtr->flags |= WM_COLORMAPS_EXPLICIT; if (wmPtr->cmapList != NULL) { - ckfree((char *) wmPtr->cmapList); + ckfree(wmPtr->cmapList); } wmPtr->cmapList = cmapList; wmPtr->cmapCount = windowObjc; @@ -1270,7 +1269,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; } return TCL_OK; @@ -1279,7 +1278,7 @@ WmCommandCmd( return TCL_ERROR; } if (wmPtr->cmdArgv != NULL) { - ckfree((char *) wmPtr->cmdArgv); + ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; @@ -1700,7 +1699,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc((unsigned) (length + 1)); + wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; @@ -1926,10 +1925,10 @@ WmIconnameCmd( } 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); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); @@ -2504,7 +2503,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; @@ -2701,7 +2700,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; @@ -2756,7 +2755,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) { @@ -3004,7 +3003,7 @@ WmTransientCmd( if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } - wmPtr->masterWindowName = ckalloc((unsigned) length+1); + wmPtr->masterWindowName = ckalloc(length+1); strcpy(wmPtr->masterWindowName, argv3); } ApplyMasterOverrideChanges(winPtr, NULL); @@ -4369,7 +4368,7 @@ TkWmAddToColormapWindows( * 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 *)); } @@ -4379,7 +4378,7 @@ TkWmAddToColormapWindows( newPtr[count-1] = winPtr; newPtr[count] = topPtr; if (oldPtr != NULL) { - ckfree((char *) oldPtr); + ckfree(oldPtr); } topPtr->wmInfoPtr->cmapList = newPtr; @@ -5384,7 +5383,7 @@ TkMacOSXMakeRealWindowExist( * Add this window to the list of toplevel windows. */ - listPtr = (TkMacOSXWindowList *) ckalloc(sizeof(TkMacOSXWindowList)); + listPtr = ckalloc(sizeof(TkMacOSXWindowList)); listPtr->nextPtr = tkMacOSXWindowListPtr; listPtr->winPtr = winPtr; tkMacOSXWindowListPtr = listPtr; @@ -5903,8 +5902,7 @@ TkWmStackorderToplevel( Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(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 @@ -5924,7 +5922,7 @@ TkWmStackorderToplevel( frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); if (frontWindow == NULL) { - ckfree((char *) windows); + ckfree(windows); windows = NULL; } else { window_ptr = windows + table.numEntries; diff --git a/carbon/tkMacOSXXStubs.c b/carbon/tkMacOSXXStubs.c index 22945aa..4262ba9 100644 --- a/carbon/tkMacOSXXStubs.c +++ b/carbon/tkMacOSXXStubs.c @@ -154,8 +154,8 @@ TkpOpenDisplay( } } - display = (Display *) ckalloc(sizeof(Display)); - screen = (Screen *) ckalloc(sizeof(Screen)); + display = ckalloc(sizeof(Display)); + screen = ckalloc(sizeof(Screen)); bzero(display, sizeof(Display)); bzero(screen, sizeof(Screen)); @@ -183,7 +183,7 @@ TkpOpenDisplay( screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24; screen->ext_data = (XExtData *) &maxBounds; - screen->root_visual = (Visual *) ckalloc(sizeof(Visual)); + screen->root_visual = ckalloc(sizeof(Visual)); screen->root_visual->visualid = 0; screen->root_visual->class = TrueColor; screen->root_visual->red_mask = 0x00FF0000; @@ -198,7 +198,7 @@ TkpOpenDisplay( TkMacOSXDisplayChanged(display); - gMacDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay)); + gMacDisplay = ckalloc(sizeof(TkDisplay)); /* * This is the quickest way to make sure that all the *Init flags get @@ -239,11 +239,11 @@ TkpCloseDisplay( gMacDisplay = NULL; if (display->screens != NULL) { if (display->screens->root_visual != NULL) { - ckfree((char *) display->screens->root_visual); + ckfree(display->screens->root_visual); } - ckfree((char *) display->screens); + ckfree(display->screens); } - ckfree((char *) display); + ckfree(display); } /* @@ -772,7 +772,7 @@ XCreateImage( XImage *ximage; display->request++; - ximage = (XImage *) ckalloc(sizeof(XImage)); + ximage = ckalloc(sizeof(XImage)); ximage->height = height; ximage->width = width; @@ -926,7 +926,7 @@ DestroyImage( } else if (image->data) { ckfree(image->data); } - ckfree((char*) image); + ckfree(image); } return 0; } diff --git a/generic/tk3d.c b/generic/tk3d.c index 393345d..47c45c4 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -463,7 +463,7 @@ Tk_Free3DBorder( prevPtr->nextPtr = borderPtr->nextPtr; } if (borderPtr->objRefCount == 0) { - ckfree((char *) borderPtr); + ckfree(borderPtr); } } @@ -535,7 +535,7 @@ FreeBorderObj( borderPtr->objRefCount--; if ((borderPtr->objRefCount == 0) && (borderPtr->resourceRefCount == 0)) { - ckfree((char *) borderPtr); + ckfree(borderPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; } diff --git a/generic/tkBind.c b/generic/tkBind.c index 8f40900..ec46650 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -715,7 +715,7 @@ TkBindInit( mainPtr->bindingTable = Tk_CreateBindingTable(mainPtr->interp); - bindInfoPtr = (BindInfo *) ckalloc(sizeof(BindInfo)); + bindInfoPtr = ckalloc(sizeof(BindInfo)); InitVirtualEventTable(&bindInfoPtr->virtualEventTable); bindInfoPtr->screenInfo.curDispPtr = NULL; bindInfoPtr->screenInfo.curScreenIndex = -1; @@ -782,14 +782,13 @@ Tk_CreateBindingTable( * table: commands are executed in this * interpreter. */ { - BindingTable *bindPtr; + BindingTable *bindPtr = ckalloc(sizeof(BindingTable)); int i; /* * Create and initialize a new binding table. */ - bindPtr = (BindingTable *) ckalloc(sizeof(BindingTable)); for (i = 0; i < EVENT_BUFFER_SIZE; i++) { bindPtr->eventRing[i].type = -1; } @@ -835,7 +834,7 @@ Tk_DeleteBindingTable( for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL; psPtr = nextPtr) { nextPtr = psPtr->nextSeqPtr; ckfree(psPtr->script); - ckfree((char *) psPtr); + ckfree(psPtr); } } @@ -845,7 +844,7 @@ Tk_DeleteBindingTable( Tcl_DeleteHashTable(&bindPtr->patternTable); Tcl_DeleteHashTable(&bindPtr->objectTable); - ckfree((char *) bindPtr); + ckfree(bindPtr); } /* @@ -926,14 +925,14 @@ Tk_CreateBinding( if ((append != 0) && (oldStr != NULL)) { size_t length1 = strlen(oldStr), length2 = strlen(script); - newStr = ckalloc((unsigned) length1 + length2 + 2); + newStr = ckalloc(length1 + length2 + 2); memcpy(newStr, oldStr, length1); newStr[length1] = '\n'; memcpy(newStr+length1+1, script, length2+1); } else { size_t length = strlen(script); - newStr = ckalloc((unsigned) length+1); + newStr = ckalloc(length + 1); memcpy(newStr, script, length+1); } if (oldStr != NULL) { @@ -1024,7 +1023,7 @@ Tk_DeleteBinding( } ckfree(psPtr->script); - ckfree((char *) psPtr); + ckfree(psPtr); return TCL_OK; } @@ -1177,7 +1176,7 @@ Tk_DeleteAllBindings( } } ckfree(psPtr->script); - ckfree((char *) psPtr); + ckfree(psPtr); } Tcl_DeleteHashEntry(hPtr); } @@ -2482,8 +2481,8 @@ DeleteVirtualEventTable( psPtr = Tcl_GetHashValue(hPtr); for ( ; psPtr != NULL; psPtr = nextPtr) { nextPtr = psPtr->nextSeqPtr; - ckfree((char *) psPtr->voPtr); - ckfree((char *) psPtr); + ckfree(psPtr->voPtr); + ckfree(psPtr); } } Tcl_DeleteHashTable(&vetPtr->patternTable); @@ -2558,7 +2557,7 @@ CreateVirtualEvent( poPtr = Tcl_GetHashValue(vhPtr); if (poPtr == NULL) { - poPtr = (PhysicalsOwned *) ckalloc(sizeof(PhysicalsOwned)); + poPtr = ckalloc(sizeof(PhysicalsOwned)); poPtr->numOwned = 0; } else { /* @@ -2573,8 +2572,8 @@ CreateVirtualEvent( return TCL_OK; } } - poPtr = (PhysicalsOwned *) ckrealloc((char *) poPtr, - sizeof(PhysicalsOwned) + poPtr->numOwned * sizeof(PatSeq *)); + poPtr = ckrealloc(poPtr, sizeof(PhysicalsOwned) + + poPtr->numOwned * sizeof(PatSeq *)); } Tcl_SetHashValue(vhPtr, poPtr); poPtr->patSeqs[poPtr->numOwned] = psPtr; @@ -2586,11 +2585,10 @@ CreateVirtualEvent( voPtr = psPtr->voPtr; if (voPtr == NULL) { - voPtr = (VirtualOwners *) ckalloc(sizeof(VirtualOwners)); + voPtr = ckalloc(sizeof(VirtualOwners)); voPtr->numOwners = 0; } else { - voPtr = (VirtualOwners *) ckrealloc((char *) voPtr, - sizeof(VirtualOwners) + voPtr = ckrealloc(voPtr, sizeof(VirtualOwners) + voPtr->numOwners * sizeof(Tcl_HashEntry *)); } psPtr->voPtr = voPtr; @@ -2717,8 +2715,8 @@ DeleteVirtualEvent( } } } - ckfree((char *) psPtr->voPtr); - ckfree((char *) psPtr); + ckfree(psPtr->voPtr); + ckfree(psPtr); } else { /* * This physical event still triggers some other virtual @@ -2755,7 +2753,7 @@ DeleteVirtualEvent( * itself should be deleted. */ - ckfree((char *) poPtr); + ckfree(poPtr); Tcl_DeleteHashEntry(vhPtr); } return TCL_OK; @@ -3739,8 +3737,7 @@ FindSequence( return NULL; } - psPtr = (PatSeq *) ckalloc((unsigned) - (sizeof(PatSeq) + (numPats-1)*sizeof(Pattern))); + psPtr = ckalloc(sizeof(PatSeq) + (numPats-1)*sizeof(Pattern)); psPtr->numPats = numPats; psPtr->script = NULL; psPtr->flags = flags; diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index f7f648f..bdf160f 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -413,7 +413,7 @@ GetBitmap( * Add information about this bitmap to our database. */ - bitmapPtr = (TkBitmap *) ckalloc(sizeof(TkBitmap)); + bitmapPtr = ckalloc(sizeof(TkBitmap)); bitmapPtr->bitmap = bitmap; bitmapPtr->width = width; bitmapPtr->height = height; @@ -505,7 +505,7 @@ Tk_DefineBitmap( NULL); return TCL_ERROR; } - predefPtr = (TkPredefBitmap *) ckalloc(sizeof(TkPredefBitmap)); + predefPtr = ckalloc(sizeof(TkPredefBitmap)); predefPtr->source = source; predefPtr->width = width; predefPtr->height = height; @@ -641,7 +641,7 @@ FreeBitmap( prevPtr->nextPtr = bitmapPtr->nextPtr; } if (bitmapPtr->objRefCount == 0) { - ckfree((char *) bitmapPtr); + ckfree(bitmapPtr); } } @@ -749,7 +749,7 @@ FreeBitmapObj( bitmapPtr->objRefCount--; if ((bitmapPtr->objRefCount == 0) && (bitmapPtr->resourceRefCount == 0)) { - ckfree((char *) bitmapPtr); + ckfree(bitmapPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; } diff --git a/generic/tkBusy.c b/generic/tkBusy.c index 320f177..3a683e3 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -526,7 +526,7 @@ CreateBusy( Window parent; Tk_FakeWin *winPtr; - busyPtr = (Busy *) ckalloc(sizeof(Busy)); + busyPtr = ckalloc(sizeof(Busy)); x = y = 0; length = strlen(Tk_Name(tkRef)); name = ckalloc(length + 6); diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index f0c4de2..58bb4c7 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -590,7 +590,7 @@ DeleteArc( Tk_DeleteOutline(display, &(arcPtr->outline)); if (arcPtr->numOutlinePoints != 0) { - ckfree((char *) arcPtr->outlinePtr); + ckfree(arcPtr->outlinePtr); } if (arcPtr->fillColor != NULL) { Tk_FreeColor(arcPtr->fillColor); @@ -1453,8 +1453,7 @@ ComputeArcOutline( */ if (arcPtr->numOutlinePoints == 0) { - arcPtr->outlinePtr = (double *) ckalloc((unsigned) - (26 * sizeof(double))); + arcPtr->outlinePtr = ckalloc(26 * sizeof(double)); arcPtr->numOutlinePoints = 22; } outlinePtr = arcPtr->outlinePtr; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 34cdfae..9be9bf6 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -408,10 +408,9 @@ LineCoords( } else { numPoints = objc/2; if (linePtr->numPoints != numPoints) { - coordPtr = (double *) - ckalloc(sizeof(double) * (unsigned) objc); + coordPtr = ckalloc(sizeof(double) * objc); if (linePtr->coordPtr != NULL) { - ckfree((char *) linePtr->coordPtr); + ckfree(linePtr->coordPtr); } linePtr->coordPtr = coordPtr; linePtr->numPoints = numPoints; @@ -430,11 +429,11 @@ LineCoords( */ if (linePtr->firstArrowPtr != NULL) { - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { @@ -561,7 +560,7 @@ ConfigureLine( && (linePtr->arrow != ARROWS_BOTH)) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if ((linePtr->lastArrowPtr != NULL) && (linePtr->arrow != ARROWS_LAST) @@ -571,7 +570,7 @@ ConfigureLine( i = 2*(linePtr->numPoints-1); linePtr->coordPtr[i] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1]; - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { @@ -614,16 +613,16 @@ DeleteLine( Tk_DeleteOutline(display, &linePtr->outline); if (linePtr->coordPtr != NULL) { - ckfree((char *) linePtr->coordPtr); + ckfree(linePtr->coordPtr); } if (linePtr->arrowGC != None) { Tk_FreeGC(display, linePtr->arrowGC); } if (linePtr->firstArrowPtr != NULL) { - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); } if (linePtr->lastArrowPtr != NULL) { - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); } } @@ -879,8 +878,7 @@ DisplayLine( if (numPoints <= MAX_STATIC_POINTS) { pointPtr = staticPoints; } else { - pointPtr = (XPoint *) - ckalloc((unsigned) numPoints * 3 * sizeof(XPoint)); + pointPtr = ckalloc(numPoints * 3 * sizeof(XPoint)); } if ((linePtr->smooth) && (linePtr->numPoints > 2)) { @@ -916,7 +914,7 @@ DisplayLine( (unsigned) intwidth+1, (unsigned) intwidth+1, 0, 64*360); } if (pointPtr != staticPoints) { - ckfree((char *) pointPtr); + ckfree(pointPtr); } /* @@ -989,8 +987,7 @@ LineInsert( linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1]; } - newCoordPtr = (double *) - ckalloc(sizeof(double) * (unsigned)(length + objc)); + newCoordPtr = ckalloc(sizeof(double) * (length + objc)); for (i=0; i<beforeThis; i++) { newCoordPtr[i] = linePtr->coordPtr[i]; } @@ -998,7 +995,7 @@ LineInsert( if (Tcl_GetDoubleFromObj(NULL, objv[i], &newCoordPtr[i + beforeThis]) != TCL_OK) { Tcl_ResetResult(Canvas(canvas)->interp); - ckfree((char *) newCoordPtr); + ckfree(newCoordPtr); return; } } @@ -1007,7 +1004,7 @@ LineInsert( newCoordPtr[i+objc] = linePtr->coordPtr[i]; } if (linePtr->coordPtr) { - ckfree((char *) linePtr->coordPtr); + ckfree(linePtr->coordPtr); } linePtr->coordPtr = newCoordPtr; length += objc ; @@ -1070,11 +1067,11 @@ LineInsert( } } if (linePtr->firstArrowPtr != NULL) { - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { @@ -1247,11 +1244,11 @@ LineDeleteCoords( } linePtr->numPoints -= count/2; if (linePtr->firstArrowPtr != NULL) { - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { @@ -1371,8 +1368,7 @@ LineToPoint( if (numPoints <= MAX_STATIC_POINTS) { linePoints = staticSpace; } else { - linePoints = (double *) - ckalloc((unsigned) (2*numPoints*sizeof(double))); + linePoints = ckalloc(2 * numPoints * sizeof(double)); } numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps, NULL, linePoints); @@ -1531,7 +1527,7 @@ LineToPoint( done: if ((linePoints != staticSpace) && (linePoints != linePtr->coordPtr)) { - ckfree((char *) linePoints); + ckfree(linePoints); } return bestDist; } @@ -1607,8 +1603,7 @@ LineToArea( if (numPoints <= MAX_STATIC_POINTS) { linePoints = staticSpace; } else { - linePoints = (double *) - ckalloc((unsigned) (2*numPoints*sizeof(double))); + linePoints = ckalloc(2 * numPoints * sizeof(double)); } numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps, NULL, linePoints); @@ -1654,7 +1649,7 @@ LineToArea( done: if ((linePoints != staticSpace) && (linePoints != linePtr->coordPtr)) { - ckfree((char *) linePoints); + ckfree(linePoints); } return result; } @@ -1699,7 +1694,7 @@ ScaleLine( if (linePtr->firstArrowPtr != NULL) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; - ckfree((char *) linePtr->firstArrowPtr); + ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { @@ -1708,7 +1703,7 @@ ScaleLine( i = 2*(linePtr->numPoints-1); linePtr->coordPtr[i] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1]; - ckfree((char *) linePtr->lastArrowPtr); + ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints; @@ -1906,7 +1901,7 @@ ParseArrowShape( Tcl_AppendResult(interp, "bad arrow shape \"", value, "\": must be list with three numbers", NULL); if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } return TCL_ERROR; } @@ -1920,10 +1915,10 @@ ParseArrowShape( != TCL_OK)) { goto syntaxError; } - linePtr->arrowShapeA = (float)a; - linePtr->arrowShapeB = (float)b; - linePtr->arrowShapeC = (float)c; - ckfree((char *) argv); + linePtr->arrowShapeA = (float) a; + linePtr->arrowShapeB = (float) b; + linePtr->arrowShapeC = (float) c; + ckfree(argv); return TCL_OK; } @@ -2153,8 +2148,7 @@ ConfigureArrows( if (linePtr->arrow != ARROWS_LAST) { poly = linePtr->firstArrowPtr; if (poly == NULL) { - poly = (double *) - ckalloc((unsigned) (2*PTS_IN_ARROW*sizeof(double))); + poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double)); poly[0] = poly[10] = linePtr->coordPtr[0]; poly[1] = poly[11] = linePtr->coordPtr[1]; linePtr->firstArrowPtr = poly; @@ -2198,8 +2192,7 @@ ConfigureArrows( coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2); poly = linePtr->lastArrowPtr; if (poly == NULL) { - poly = (double *) - ckalloc((unsigned) (2*PTS_IN_ARROW*sizeof(double))); + poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double)); poly[0] = poly[10] = coordPtr[2]; poly[1] = poly[11] = coordPtr[3]; linePtr->lastArrowPtr = poly; @@ -2348,14 +2341,13 @@ LineToPostscript( linePtr->numPoints, linePtr->splineSteps, NULL, NULL); pointPtr = staticPoints; if (numPoints > MAX_STATIC_POINTS) { - pointPtr = (double *) - ckalloc((unsigned) (numPoints * 2 * sizeof(double))); + pointPtr = ckalloc(numPoints * 2 * sizeof(double)); } numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr); Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints); if (pointPtr != staticPoints) { - ckfree((char *) pointPtr); + ckfree(pointPtr); } } diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index c64dcc1..b043aad 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -367,7 +367,7 @@ PolygonCoords( numPoints = objc/2; if (polyPtr->pointsAllocated <= numPoints) { if (polyPtr->coordPtr != NULL) { - ckfree((char *) polyPtr->coordPtr); + ckfree(polyPtr->coordPtr); } /* @@ -375,8 +375,7 @@ PolygonCoords( * another point to close the polygon. */ - polyPtr->coordPtr = (double *) - ckalloc(sizeof(double) * (unsigned)(objc+2)); + polyPtr->coordPtr = ckalloc(sizeof(double) * (objc+2)); polyPtr->pointsAllocated = numPoints+1; } for (i = objc-1; i >= 0; i--) { @@ -572,7 +571,7 @@ DeletePolygon( Tk_DeleteOutline(display, &polyPtr->outline); if (polyPtr->coordPtr != NULL) { - ckfree((char *) polyPtr->coordPtr); + ckfree(polyPtr->coordPtr); } if (polyPtr->fillColor != NULL) { Tk_FreeColor(polyPtr->fillColor); @@ -825,7 +824,7 @@ TkFillPolygon( if (numPoints <= MAX_STATIC_POINTS) { pointPtr = staticPoints; } else { - pointPtr = (XPoint *) ckalloc((unsigned) numPoints * sizeof(XPoint)); + pointPtr = ckalloc(numPoints * sizeof(XPoint)); } for (i=0, pPtr=pointPtr ; i<numPoints; i+=1, coordPtr+=2, pPtr++) { @@ -847,7 +846,7 @@ TkFillPolygon( CoordModeOrigin); } if (pointPtr != staticPoints) { - ckfree((char *) pointPtr); + ckfree(pointPtr); } } @@ -971,8 +970,7 @@ DisplayPolygon( if (numPoints <= MAX_STATIC_POINTS) { pointPtr = staticPoints; } else { - pointPtr = (XPoint *) - ckalloc((unsigned) numPoints * sizeof(XPoint)); + pointPtr = ckalloc(numPoints * sizeof(XPoint)); } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL); @@ -985,7 +983,7 @@ DisplayPolygon( numPoints, CoordModeOrigin); } if (pointPtr != staticPoints) { - ckfree((char *) pointPtr); + ckfree(pointPtr); } } Tk_ResetOutlineGC(canvas, itemPtr, &polyPtr->outline); @@ -1039,15 +1037,14 @@ PolygonInsert( while (beforeThis < 0) { beforeThis += length; } - newCoordPtr = (double *) - ckalloc(sizeof(double) * (unsigned)(length + 2 + objc)); + newCoordPtr = ckalloc(sizeof(double) * (length + 2 + objc)); for (i=0; i<beforeThis; i++) { newCoordPtr[i] = polyPtr->coordPtr[i]; } for (i=0; i<objc; i++) { if (Tcl_GetDoubleFromObj(NULL, objv[i], &newCoordPtr[i+beforeThis]) != TCL_OK){ - ckfree((char *) newCoordPtr); + ckfree(newCoordPtr); return; } } @@ -1056,7 +1053,7 @@ PolygonInsert( newCoordPtr[i+objc] = polyPtr->coordPtr[i]; } if (polyPtr->coordPtr) { - ckfree((char *) polyPtr->coordPtr); + ckfree(polyPtr->coordPtr); } length += objc; polyPtr->coordPtr = newCoordPtr; @@ -1200,7 +1197,7 @@ PolygonDeleteCoords( if (count >= length) { polyPtr->numPoints = 0; if (polyPtr->coordPtr != NULL) { - ckfree((char *) polyPtr->coordPtr); + ckfree(polyPtr->coordPtr); } ComputePolygonBbox(canvas, polyPtr); return; @@ -1289,8 +1286,7 @@ PolygonToPoint( if (numPoints <= MAX_STATIC_POINTS) { polyPoints = staticSpace; } else { - polyPoints = (double *) - ckalloc((unsigned) 2*numPoints*sizeof(double)); + polyPoints = ckalloc(2 * numPoints * sizeof(double)); } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints); @@ -1408,7 +1404,7 @@ PolygonToPoint( donepoint: if (polyPoints != staticSpace && polyPoints != polyPtr->coordPtr) { - ckfree((char *) polyPoints); + ckfree(polyPoints); } return bestDist; } @@ -1499,8 +1495,7 @@ PolygonToArea( if (numPoints <= MAX_STATIC_POINTS) { polyPoints = staticSpace; } else { - polyPoints = (double *) - ckalloc((unsigned) 2*numPoints*sizeof(double)); + polyPoints = ckalloc(2 * numPoints * sizeof(double)); } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints); @@ -1603,7 +1598,7 @@ PolygonToArea( donearea: if ((polyPoints != staticSpace) && (polyPoints != polyPtr->coordPtr)) { - ckfree((char *) polyPoints); + ckfree(polyPoints); } return inside; } diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index 1af0a3a..c5b582d 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -1220,7 +1220,7 @@ TkPostscriptImage( */ ncolors = visual->map_entries; - cdata.colors = (XColor *) ckalloc(sizeof(XColor) * ncolors); + cdata.colors = ckalloc(sizeof(XColor) * ncolors); cdata.ncolors = ncolors; if (visual->class == DirectColor || visual->class == TrueColor) { @@ -1295,7 +1295,7 @@ TkPostscriptImage( "Can't generate Postscript for images more than %d pixels wide", maxWidth); Tcl_AppendResult(interp, buffer, NULL); - ckfree((char *) cdata.colors); + ckfree(cdata.colors); return TCL_ERROR; } @@ -1409,7 +1409,7 @@ TkPostscriptImage( sprintf(buffer, "0 %d translate\n", rows); Tcl_AppendResult(interp, buffer, NULL); } - ckfree((char *) cdata.colors); + ckfree(cdata.colors); return TCL_OK; } diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index ce587af..9477c63 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -1026,7 +1026,7 @@ TextInsert( return; } - newStr = ckalloc((unsigned) textPtr->numBytes + byteCount + 1); + newStr = ckalloc(textPtr->numBytes + byteCount + 1); memcpy(newStr, text, (size_t) byteIndex); strcpy(newStr + byteIndex, string); strcpy(newStr + byteIndex + byteCount, text + byteIndex); @@ -1107,7 +1107,7 @@ TextDeleteChars( byteCount = Tcl_UtfAtIndex(text + byteIndex, charsRemoved) - (text + byteIndex); - newStr = ckalloc((unsigned) (textPtr->numBytes + 1 - byteCount)); + newStr = ckalloc(textPtr->numBytes + 1 - byteCount); memcpy(newStr, text, (size_t) byteIndex); strcpy(newStr + byteIndex, text + byteIndex + byteCount); diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 9c8e576..964e2af 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -412,12 +412,12 @@ Tk_CanvasTagsParseProc( */ if (itemPtr->tagSpace < argc) { - newPtr = (Tk_Uid *) ckalloc((unsigned) (argc * sizeof(Tk_Uid))); + newPtr = ckalloc(argc * sizeof(Tk_Uid)); for (i = itemPtr->numTags-1; i >= 0; i--) { newPtr[i] = itemPtr->tagPtr[i]; } if (itemPtr->tagPtr != itemPtr->staticTagSpace) { - ckfree((char *) itemPtr->tagPtr); + ckfree(itemPtr->tagPtr); } itemPtr->tagPtr = newPtr; itemPtr->tagSpace = argc; @@ -426,7 +426,7 @@ Tk_CanvasTagsParseProc( for (i = 0; i < argc; i++) { itemPtr->tagPtr[i] = Tk_GetUid(argv[i]); } - ckfree((char *) argv); + ckfree(argv); return TCL_OK; } @@ -545,7 +545,7 @@ TkCanvasDashPrintProc( if (i < 0) { i = -i; *freeProcPtr = TCL_DYNAMIC; - buffer = (char *) ckalloc((unsigned int) (i+1)); + buffer = ckalloc(i + 1); p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; memcpy(buffer, p, (unsigned int) i); buffer[i] = 0; @@ -554,7 +554,7 @@ TkCanvasDashPrintProc( *freeProcPtr = NULL; return ""; } - buffer = (char *) ckalloc((unsigned int) (4*i)); + buffer = ckalloc(4 * i); *freeProcPtr = TCL_DYNAMIC; p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; @@ -590,14 +590,12 @@ InitSmoothMethods( { SmoothAssocData *methods, *ptr; - methods = (SmoothAssocData *) ckalloc(sizeof(SmoothAssocData)); + methods = ckalloc(sizeof(SmoothAssocData)); methods->smooth.name = tkRawSmoothMethod.name; methods->smooth.coordProc = tkRawSmoothMethod.coordProc; methods->smooth.postscriptProc = tkRawSmoothMethod.postscriptProc; - methods->nextPtr = (SmoothAssocData *) ckalloc(sizeof(SmoothAssocData)); - - ptr = methods->nextPtr; + ptr = methods->nextPtr = ckalloc(sizeof(SmoothAssocData)); ptr->smooth.name = tkBezierSmoothMethod.name; ptr->smooth.coordProc = tkBezierSmoothMethod.coordProc; ptr->smooth.postscriptProc = tkBezierSmoothMethod.postscriptProc; @@ -653,11 +651,11 @@ Tk_CreateSmoothMethod( } else { prevPtr->nextPtr = typePtr2->nextPtr; } - ckfree((char *) typePtr2); + ckfree(typePtr2); break; } } - ptr = (SmoothAssocData *) ckalloc(sizeof(SmoothAssocData)); + ptr = ckalloc(sizeof(SmoothAssocData)); ptr->smooth.name = smooth->name; ptr->smooth.coordProc = smooth->coordProc; ptr->smooth.postscriptProc = smooth->postscriptProc; @@ -693,7 +691,7 @@ SmoothMethodCleanupProc( while (methods != NULL) { ptr = methods; methods = methods->nextPtr; - ckfree((char *) ptr); + ckfree(ptr); } } /* @@ -880,10 +878,10 @@ Tk_GetDash( } if ((unsigned) ABS(dash->number) > sizeof(char *)) { - ckfree((char *) dash->pattern.pt); + ckfree(dash->pattern.pt); } if (argc > (int)sizeof(char *)) { - dash->pattern.pt = pt = ckalloc((unsigned) argc); + dash->pattern.pt = pt = ckalloc(argc); } else { pt = dash->pattern.array; } @@ -904,7 +902,7 @@ Tk_GetDash( } if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } return TCL_OK; @@ -917,10 +915,10 @@ Tk_GetDash( "\": must be a list of integers or a format like \"-..\"", NULL); syntaxError: if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } if ((unsigned) ABS(dash->number) > sizeof(char *)) { - ckfree((char *) dash->pattern.pt); + ckfree(dash->pattern.pt); } dash->number = 0; return TCL_ERROR; @@ -992,13 +990,13 @@ Tk_DeleteOutline( Tk_FreeGC(display, outline->gc); } if ((unsigned) ABS(outline->dash.number) > sizeof(char *)) { - ckfree((char *) outline->dash.pattern.pt); + ckfree(outline->dash.pattern.pt); } if ((unsigned) ABS(outline->activeDash.number) > sizeof(char *)) { - ckfree((char *) outline->activeDash.pattern.pt); + ckfree(outline->activeDash.pattern.pt); } if ((unsigned) ABS(outline->disabledDash.number) > sizeof(char *)) { - ckfree((char *) outline->disabledDash.pattern.pt); + ckfree(outline->disabledDash.pattern.pt); } if (outline->color != NULL) { Tk_FreeColor(outline->color); @@ -1210,7 +1208,7 @@ Tk_ChangeOutlineGC( int i = -dash->number; p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; - q = (char *) ckalloc(2 * (unsigned) i); + q = ckalloc(2 * i); i = DashConvert(q, p, i, width); XSetDashes(Canvas(canvas)->display, outline->gc, outline->offset, q,i); ckfree(q); @@ -1410,10 +1408,10 @@ Tk_CanvasPsOutline( Tcl_AppendResult(interp, string, NULL); if (dash->number > 10) { - str = (char *) ckalloc((unsigned) (1 + 4*dash->number)); + str = ckalloc(1 + 4*dash->number); } else if (dash->number < -5) { - str = (char *) ckalloc((unsigned) (1 - 8*dash->number)); - lptr = (char *) ckalloc((unsigned) (1 - 2*dash->number)); + str = ckalloc(1 - 8*dash->number); + lptr = ckalloc(1 - 2*dash->number); } ptr = ((unsigned) ABS(dash->number) > sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; @@ -1704,7 +1702,7 @@ TkCanvTranslatePath( if (numVertex*12 <= (int) (sizeof(staticSpace) / sizeof(double))) { tempArr = staticSpace; } else { - tempArr = (double *) ckalloc(numVertex * 12 * sizeof(double)); + tempArr = ckalloc(numVertex * 12 * sizeof(double)); } for (i=0; i<numVertex*2; i++){ tempArr[i] = coordArr[i]; @@ -1844,7 +1842,7 @@ TkCanvTranslatePath( TranslateAndAppendCoords(canvPtr, a[i*2], a[i*2+1], outArr, i); } if (tempArr != staticSpace) { - ckfree((char *) tempArr); + ckfree(tempArr); } return numOutput; } diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 275b97f..1a3ed52 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -398,7 +398,7 @@ ItemConfigure( result = itemPtr->typePtr->configProc(interp, (Tk_Canvas) canvasPtr, itemPtr, objc, (Tcl_Obj **) args, TK_CONFIG_ARGV_ONLY); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } } return result; @@ -447,7 +447,7 @@ ItemCoords( result = itemPtr->typePtr->coordProc(interp, (Tk_Canvas) canvasPtr, itemPtr, objc, (Tcl_Obj **) args); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } } return result; @@ -473,7 +473,7 @@ ItemCreate( result = itemPtr->typePtr->createProc(interp, (Tk_Canvas) canvasPtr, itemPtr, objc-3, (Tcl_Obj **) args); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } } return result; @@ -664,7 +664,7 @@ Tk_CanvasObjCmd( * pointers). */ - canvasPtr = (TkCanvas *) ckalloc(sizeof(TkCanvas)); + canvasPtr = ckalloc(sizeof(TkCanvas)); canvasPtr->tkwin = newWin; canvasPtr->display = Tk_Display(newWin); canvasPtr->interp = interp; @@ -1292,7 +1292,7 @@ CanvasWidgetCmd( } typePtr = matchPtr; - itemPtr = (Tk_Item *) ckalloc((unsigned) typePtr->itemSize); + itemPtr = ckalloc(typePtr->itemSize); itemPtr->id = canvasPtr->nextId; canvasPtr->nextId++; itemPtr->tagPtr = itemPtr->staticTagSpace; @@ -1303,7 +1303,7 @@ CanvasWidgetCmd( itemPtr->redraw_flags = 0; if (ItemCreate(canvasPtr, itemPtr, objc, objv) != TCL_OK) { - ckfree((char *) itemPtr); + ckfree(itemPtr); result = TCL_ERROR; goto done; } @@ -1386,7 +1386,7 @@ CanvasWidgetCmd( } ItemDelete(canvasPtr, itemPtr); if (itemPtr->tagPtr != itemPtr->staticTagSpace) { - ckfree((char *) itemPtr->tagPtr); + ckfree(itemPtr->tagPtr); } entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char *) INT2PTR(itemPtr->id)); @@ -1406,7 +1406,7 @@ CanvasWidgetCmd( if (canvasPtr->lastItemPtr == itemPtr) { canvasPtr->lastItemPtr = itemPtr->prevPtr; } - ckfree((char *) itemPtr); + ckfree(itemPtr); if (itemPtr == canvasPtr->currentItemPtr) { canvasPtr->currentItemPtr = NULL; canvasPtr->flags |= REPICK_NEEDED; @@ -1748,7 +1748,7 @@ CanvasWidgetCmd( result = TkCanvPostscriptCmd(canvasPtr, interp, objc, args); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } break; } @@ -2032,7 +2032,7 @@ CanvasWidgetCmd( type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } switch (type) { case TK_SCROLL_ERROR: @@ -2079,7 +2079,7 @@ CanvasWidgetCmd( type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count); if (args != NULL) { - ckfree((char *) args); + ckfree(args); } switch (type) { case TK_SCROLL_ERROR: @@ -2157,9 +2157,9 @@ DestroyCanvas( canvasPtr->firstItemPtr = itemPtr->nextPtr; ItemDelete(canvasPtr, itemPtr); if (itemPtr->tagPtr != itemPtr->staticTagSpace) { - ckfree((char *) itemPtr->tagPtr); + ckfree(itemPtr->tagPtr); } - ckfree((char *) itemPtr); + ckfree(itemPtr); } /* @@ -2185,7 +2185,7 @@ DestroyCanvas( } Tk_FreeOptions(configSpecs, (char *) canvasPtr, canvasPtr->display, 0); canvasPtr->tkwin = NULL; - ckfree((char *) canvasPtr); + ckfree(canvasPtr); } /* @@ -2307,7 +2307,7 @@ ConfigureCanvas( canvasPtr->regionString, "\"", NULL); badRegion: ckfree(canvasPtr->regionString); - ckfree((char *) argv2); + ckfree(argv2); canvasPtr->regionString = NULL; return TCL_ERROR; } @@ -2321,7 +2321,7 @@ ConfigureCanvas( argv2[3], &canvasPtr->scrollY2) != TCL_OK)) { goto badRegion; } - ckfree((char *) argv2); + ckfree(argv2); } flags = canvasPtr->tsoffset.flags; @@ -3278,7 +3278,7 @@ TagSearchExprInit( TagSearchExpr *expr = *exprPtrPtr; if (expr == NULL) { - expr = (TagSearchExpr *) ckalloc(sizeof(TagSearchExpr)); + expr = ckalloc(sizeof(TagSearchExpr)); expr->allocated = 0; expr->uids = NULL; expr->next = NULL; @@ -3309,9 +3309,9 @@ TagSearchExprDestroy( { if (expr != NULL) { if (expr->uids) { - ckfree((char *) expr->uids); + ckfree(expr->uids); } - ckfree((char *) expr); + ckfree(expr); } } @@ -3359,7 +3359,7 @@ TagSearchScan( * Allocate primary search struct on first call. */ - *searchPtrPtr = searchPtr = (TagSearch *) ckalloc(sizeof(TagSearch)); + *searchPtrPtr = searchPtr = ckalloc(sizeof(TagSearch)); searchPtr->expr = NULL; /* @@ -3513,8 +3513,8 @@ TagSearchDestroy( { if (searchPtr) { TagSearchExprDestroy(searchPtr->expr); - ckfree((char *) searchPtr->rewritebuffer); - ckfree((char *) searchPtr); + ckfree(searchPtr->rewritebuffer); + ckfree(searchPtr); } } @@ -3567,11 +3567,10 @@ TagSearchScanExpr( if (expr->index >= expr->allocated-1) { expr->allocated += 15; if (expr->uids) { - expr->uids = (Tk_Uid *) ckrealloc((char *) expr->uids, + expr->uids = ckrealloc(expr->uids, expr->allocated * sizeof(Tk_Uid)); } else { - expr->uids = (Tk_Uid *) - ckalloc(expr->allocated * sizeof(Tk_Uid)); + expr->uids = ckalloc(expr->allocated * sizeof(Tk_Uid)); } } @@ -4191,12 +4190,11 @@ DoItem( Tk_Uid *newTagPtr; itemPtr->tagSpace += 5; - newTagPtr = (Tk_Uid *) - ckalloc((unsigned) itemPtr->tagSpace * sizeof(Tk_Uid)); + newTagPtr = ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid)); memcpy((void *) newTagPtr, itemPtr->tagPtr, itemPtr->numTags * sizeof(Tk_Uid)); if (itemPtr->tagPtr != itemPtr->staticTagSpace) { - ckfree((char *) itemPtr->tagPtr); + ckfree(itemPtr->tagPtr); } itemPtr->tagPtr = newTagPtr; tagPtr = &itemPtr->tagPtr[itemPtr->numTags]; @@ -5132,8 +5130,7 @@ CanvasDoEvent( if (numObjects <= NUM_STATIC) { objectPtr = staticObjects; } else { - objectPtr = (ClientData *) - ckalloc((unsigned) numObjects * sizeof(ClientData)); + objectPtr = ckalloc(numObjects * sizeof(ClientData)); } #ifdef USE_OLD_TAG_SEARCH objectPtr[0] = (ClientData) Tk_GetUid("all"); @@ -5170,7 +5167,7 @@ CanvasDoEvent( numObjects, objectPtr); } if (objectPtr != staticObjects) { - ckfree((char *) objectPtr); + ckfree(objectPtr); } } @@ -5712,7 +5709,7 @@ TkGetStringsFromObjs( if (objc <= 0) { return NULL; } - argv = (const char **) ckalloc((objc+1) * sizeof(char *)); + argv = ckalloc((objc+1) * sizeof(char *)); for (i = 0; i < objc; i++) { argv[i] = Tcl_GetString(objv[i]); } diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index e2064c1..bf79366 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -269,12 +269,12 @@ Tk_ClipboardClear( cbPtr = nextCbPtr) { ckfree(cbPtr->buffer); nextCbPtr = cbPtr->nextPtr; - ckfree((char *) cbPtr); + ckfree(cbPtr); } nextTargetPtr = targetPtr->nextPtr; Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, targetPtr->type); - ckfree((char *) targetPtr); + ckfree(targetPtr); } dispPtr->clipTargetPtr = NULL; @@ -360,7 +360,7 @@ Tk_ClipboardAppend( } } if (targetPtr == NULL) { - targetPtr = (TkClipboardTarget *) ckalloc(sizeof(TkClipboardTarget)); + targetPtr = ckalloc(sizeof(TkClipboardTarget)); targetPtr->type = type; targetPtr->format = format; targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL; @@ -380,7 +380,7 @@ Tk_ClipboardAppend( * Append a new buffer to the buffer chain. */ - cbPtr = (TkClipboardBuffer *) ckalloc(sizeof(TkClipboardBuffer)); + cbPtr = ckalloc(sizeof(TkClipboardBuffer)); cbPtr->nextPtr = NULL; if (targetPtr->lastBufferPtr != NULL) { targetPtr->lastBufferPtr->nextPtr = cbPtr; @@ -390,7 +390,7 @@ Tk_ClipboardAppend( targetPtr->lastBufferPtr = cbPtr; cbPtr->length = strlen(buffer); - cbPtr->buffer = (char *) ckalloc((unsigned) (cbPtr->length + 1)); + cbPtr->buffer = ckalloc(cbPtr->length + 1); strcpy(cbPtr->buffer, buffer); TkSelUpdateClipboard((TkWindow *) dispPtr->clipWindow, targetPtr); diff --git a/generic/tkCmds.c b/generic/tkCmds.c index cf80c02..c00cb71 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -284,8 +284,7 @@ TkBindEventProc( */ if (winPtr->numTags > MAX_OBJS) { - objPtr = (ClientData *) - ckalloc((unsigned) winPtr->numTags * sizeof(ClientData)); + objPtr = ckalloc(winPtr->numTags * sizeof(ClientData)); } for (i = 0; i < winPtr->numTags; i++) { p = winPtr->tagPtr[i]; @@ -319,7 +318,7 @@ TkBindEventProc( Tk_BindEvent(winPtr->mainPtr->bindingTable, eventPtr, (Tk_Window) winPtr, count, objPtr); if (objPtr != objects) { - ckfree((char *) objPtr); + ckfree(objPtr); } } @@ -401,8 +400,7 @@ Tk_BindtagsObjCmd( } winPtr->numTags = length; - winPtr->tagPtr = (ClientData *) - ckalloc((unsigned) length * sizeof(ClientData)); + winPtr->tagPtr = ckalloc(length * sizeof(ClientData)); for (i = 0; i < length; i++) { p = Tcl_GetString(tags[i]); if (p[0] == '.') { @@ -415,7 +413,7 @@ Tk_BindtagsObjCmd( * is one. */ - copy = ckalloc((unsigned) strlen(p) + 1); + copy = ckalloc(strlen(p) + 1); strcpy(copy, p); winPtr->tagPtr[i] = (ClientData) copy; } else { @@ -458,10 +456,10 @@ TkFreeBindingTags( * have to be freed. */ - ckfree((char *) p); + ckfree(p); } } - ckfree((char *) winPtr->tagPtr); + ckfree(winPtr->tagPtr); winPtr->numTags = 0; winPtr->tagPtr = NULL; } diff --git a/generic/tkColor.c b/generic/tkColor.c index 2035ec4..f1a8680 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -499,7 +499,7 @@ Tk_FreeColor( */ if (tkColPtr->objRefCount == 0) { - ckfree((char *) tkColPtr); + ckfree(tkColPtr); } } @@ -571,7 +571,7 @@ FreeColorObj( tkColPtr->objRefCount--; if ((tkColPtr->objRefCount == 0) && (tkColPtr->resourceRefCount == 0)) { - ckfree((char *) tkColPtr); + ckfree(tkColPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; } diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 8669b1b..ac5ff5d 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -191,10 +191,9 @@ Tk_CreateOptionTable( * doesn't already exist. */ - hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, - NULL); + hashTablePtr = Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); if (hashTablePtr == NULL) { - hashTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); + hashTablePtr = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(hashTablePtr, TCL_ONE_WORD_KEYS); Tcl_SetAssocData(interp, OPTION_HASH_KEY, DestroyOptionHashTable, hashTablePtr); @@ -222,8 +221,7 @@ Tk_CreateOptionTable( for (specPtr = templatePtr; specPtr->type != TK_OPTION_END; specPtr++) { numOptions++; } - tablePtr = (OptionTable *) (ckalloc(sizeof(OptionTable) - + (numOptions * sizeof(Option)))); + tablePtr = ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option))); tablePtr->refCount = 1; tablePtr->refCount2 = 1; tablePtr->hashEntryPtr = hashEntryPtr; @@ -363,7 +361,7 @@ Tk_DeleteOptionTable( Tcl_DeleteHashEntry(tablePtr->hashEntryPtr); tablePtr->refCount2--; if (tablePtr->refCount2 <= 0) { - ckfree((char *) tablePtr); + ckfree(tablePtr); } } @@ -417,7 +415,7 @@ DestroyOptionHashTable( Tk_DeleteOptionTable((Tk_OptionTable) tablePtr); } Tcl_DeleteHashTable(hashTablePtr); - ckfree((char *) hashTablePtr); + ckfree(hashTablePtr); } /* @@ -729,7 +727,7 @@ DoObjConfig( if (internalPtr != NULL) { if (valuePtr != NULL) { value = Tcl_GetStringFromObj(valuePtr, &length); - newStr = ckalloc((unsigned) (length + 1)); + newStr = ckalloc(length + 1); strcpy(newStr, value); } else { newStr = NULL; @@ -1266,7 +1264,7 @@ FreeOptionInternalRep( tablePtr->refCount2--; if (tablePtr->refCount2 <= 0) { - ckfree((char *)tablePtr); + ckfree(tablePtr); } objPtr->typePtr = NULL; objPtr->internalRep.twoPtrValue.ptr1 = NULL; @@ -1362,7 +1360,7 @@ Tk_SetOptions( * more space. */ - newSavePtr = (Tk_SavedOptions *) ckalloc(sizeof(Tk_SavedOptions)); + newSavePtr = ckalloc(sizeof(Tk_SavedOptions)); newSavePtr->recordPtr = recordPtr; newSavePtr->tkwin = tkwin; newSavePtr->numItems = 0; @@ -1438,7 +1436,7 @@ Tk_RestoreSavedOptions( if (savePtr->nextPtr != NULL) { Tk_RestoreSavedOptions(savePtr->nextPtr); - ckfree((char *) savePtr->nextPtr); + ckfree(savePtr->nextPtr); savePtr->nextPtr = NULL; } for (i = savePtr->numItems - 1; i >= 0; i--) { @@ -1573,7 +1571,7 @@ Tk_FreeSavedOptions( if (savePtr->nextPtr != NULL) { Tk_FreeSavedOptions(savePtr->nextPtr); - ckfree((char *) savePtr->nextPtr); + ckfree(savePtr->nextPtr); } for (count = savePtr->numItems, savedOptionPtr = &savePtr->items[savePtr->numItems-1]; diff --git a/generic/tkConsole.c b/generic/tkConsole.c index 7f496fb..cb16ca2 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -266,13 +266,13 @@ Tk_InitConsoleChannels( * interp for it to live in. */ - info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); + info = ckalloc(sizeof(ConsoleInfo)); info->consoleInterp = NULL; info->interp = NULL; info->refCount = 0; if (doIn) { - ChannelData *data = (ChannelData *) ckalloc(sizeof(ChannelData)); + ChannelData *data = ckalloc(sizeof(ChannelData)); data->info = info; data->info->refCount++; @@ -289,7 +289,7 @@ Tk_InitConsoleChannels( } if (doOut) { - ChannelData *data = (ChannelData *) ckalloc(sizeof(ChannelData)); + ChannelData *data = ckalloc(sizeof(ChannelData)); data->info = info; data->info->refCount++; @@ -306,7 +306,7 @@ Tk_InitConsoleChannels( } if (doErr) { - ChannelData *data = (ChannelData *) ckalloc(sizeof(ChannelData)); + ChannelData *data = ckalloc(sizeof(ChannelData)); data->info = info; data->info->refCount++; @@ -380,11 +380,17 @@ Tk_CreateConsoleWindow( ChannelData *data = (ChannelData *) Tcl_GetChannelInstanceData(chan); info = data->info; if (info->consoleInterp) { - /* New ConsoleInfo for a new console window */ - info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); + /* + * New ConsoleInfo for a new console window. + */ + + info = ckalloc(sizeof(ConsoleInfo)); info->refCount = 0; - /* Update any console channels to make use of the new console */ + /* + * Update any console channels to make use of the new console. + */ + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDIN)) == &consoleChannelType) { data = (ChannelData *) Tcl_GetChannelInstanceData(chan); @@ -408,7 +414,7 @@ Tk_CreateConsoleWindow( } } } else { - info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); + info = ckalloc(sizeof(ConsoleInfo)); info->refCount = 0; } @@ -457,7 +463,7 @@ Tk_CreateConsoleWindow( Tk_DeleteEventHandler(mainWindow, StructureNotifyMask, ConsoleEventProc, info); if (--info->refCount <= 0) { - ckfree((char *) info); + ckfree(info); } } goto error; @@ -585,10 +591,10 @@ ConsoleClose( * Assuming the Tcl_Interp * fields must already be NULL. */ - ckfree((char *) info); + ckfree(info); } } - ckfree((char *) data); + ckfree(data); return 0; } @@ -866,7 +872,7 @@ InterpDeleteProc( info->consoleInterp = NULL; } if (--info->refCount <= 0) { - ckfree((char *) info); + ckfree(info); } } @@ -897,7 +903,7 @@ ConsoleDeleteProc( Tcl_DeleteInterp(info->consoleInterp); } if (--info->refCount <= 0) { - ckfree((char *) info); + ckfree(info); } } @@ -934,7 +940,7 @@ ConsoleEventProc( } if (--info->refCount <= 0) { - ckfree((char *) info); + ckfree(info); } } } diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 5ca7b07..59e3477 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -482,7 +482,7 @@ FreeCursor( } TkpFreeCursor(cursorPtr); if (cursorPtr->objRefCount == 0) { - ckfree((char *) cursorPtr); + ckfree(cursorPtr); } } @@ -591,7 +591,7 @@ FreeCursorObj( cursorPtr->objRefCount--; if ((cursorPtr->objRefCount == 0) && (cursorPtr->resourceRefCount == 0)) { - ckfree((char *) cursorPtr); + ckfree(cursorPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; } diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 93f14a2..1db3888 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -509,7 +509,7 @@ Tk_EntryObjCmd( * initialized as memset covers the rest. */ - entryPtr = (Entry *) ckalloc(sizeof(Entry)); + entryPtr = ckalloc(sizeof(Entry)); memset(entryPtr, 0, sizeof(Entry)); entryPtr->tkwin = tkwin; @@ -1016,7 +1016,7 @@ DestroyEntry( * Tk_FreeOptions handle all the standard option-related stuff. */ - ckfree((char *)entryPtr->string); + ckfree(entryPtr->string); if (entryPtr->textVarName != NULL) { Tcl_UntraceVar(entryPtr->interp, entryPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, @@ -1031,7 +1031,7 @@ DestroyEntry( } Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler); if (entryPtr->displayString != entryPtr->string) { - ckfree((char *)entryPtr->displayString); + ckfree(entryPtr->displayString); } if (entryPtr->type == TK_SPINBOX) { Spinbox *sbPtr = (Spinbox *) entryPtr; @@ -1050,7 +1050,7 @@ DestroyEntry( Tcl_Release(entryPtr->tkwin); entryPtr->tkwin = NULL; - ckfree((char *) entryPtr); + ckfree(entryPtr); } /* @@ -1874,7 +1874,7 @@ EntryComputeGeometry( char *p; if (entryPtr->displayString != entryPtr->string) { - ckfree((char *)entryPtr->displayString); + ckfree(entryPtr->displayString); entryPtr->displayString = entryPtr->string; entryPtr->numDisplayBytes = entryPtr->numBytes; } @@ -1900,7 +1900,7 @@ EntryComputeGeometry( size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; - p = (char *) ckalloc((unsigned) (entryPtr->numDisplayBytes + 1)); + p = ckalloc(entryPtr->numDisplayBytes + 1); entryPtr->displayString = p; for (i = entryPtr->numChars; --i >= 0; ) { @@ -2017,7 +2017,7 @@ InsertChars( } newByteCount = entryPtr->numBytes + byteCount + 1; - newStr = ckalloc((unsigned) newByteCount); + newStr = ckalloc(newByteCount); memcpy(newStr, string, byteIndex); strcpy(newStr + byteIndex, value); strcpy(newStr + byteIndex + byteCount, string + byteIndex); @@ -2030,7 +2030,7 @@ InsertChars( return; } - ckfree((char *)string); + ckfree(string); entryPtr->string = newStr; /* @@ -2117,11 +2117,11 @@ DeleteChars( byteCount = Tcl_UtfAtIndex(string + byteIndex, count) - (string+byteIndex); newByteCount = entryPtr->numBytes + 1 - byteCount; - newStr = ckalloc((unsigned) newByteCount); + newStr = ckalloc(newByteCount); memcpy(newStr, string, (size_t) byteIndex); strcpy(newStr + byteIndex, string + byteIndex + byteCount); - toDelete = ckalloc((unsigned) (byteCount + 1)); + toDelete = ckalloc(byteCount + 1); memcpy(toDelete, string + byteIndex, (size_t) byteCount); toDelete[byteCount] = '\0'; @@ -2135,7 +2135,7 @@ DeleteChars( } ckfree(toDelete); - ckfree((char *)entryPtr->string); + ckfree(entryPtr->string); entryPtr->string = newStr; entryPtr->numChars -= count; entryPtr->numBytes -= byteCount; @@ -2293,7 +2293,7 @@ EntrySetValue( * during validation */ - char *tmp = (char *) ckalloc((unsigned) (valueLen + 1)); + char *tmp = ckalloc(valueLen + 1); strcpy(tmp, value); value = tmp; @@ -2311,18 +2311,18 @@ EntrySetValue( if (entryPtr->flags & VALIDATE_ABORT) { entryPtr->flags &= ~VALIDATE_ABORT; - ckfree((char *)value); + ckfree(value); return; } } oldSource = entryPtr->string; - ckfree((char *)entryPtr->string); + ckfree(entryPtr->string); if (malloced) { entryPtr->string = value; } else { - char *tmp = ckalloc((unsigned) (valueLen + 1)); + char *tmp = ckalloc(valueLen + 1); strcpy(tmp, value); entryPtr->string = tmp; @@ -3526,7 +3526,7 @@ Tk_SpinboxObjCmd( * initialized as memset covers the rest. */ - sbPtr = (Spinbox *) ckalloc(sizeof(Spinbox)); + sbPtr = ckalloc(sizeof(Spinbox)); entryPtr = (Entry *) sbPtr; memset(sbPtr, 0, sizeof(Spinbox)); diff --git a/generic/tkError.c b/generic/tkError.c index 426c457..6facc53 100644 --- a/generic/tkError.c +++ b/generic/tkError.c @@ -109,7 +109,7 @@ Tk_CreateErrorHandler( * Create the handler record. */ - errorPtr = (TkErrorHandler *) ckalloc(sizeof(TkErrorHandler)); + errorPtr = ckalloc(sizeof(TkErrorHandler)); errorPtr->dispPtr = dispPtr; errorPtr->firstRequest = NextRequest(display); errorPtr->lastRequest = (unsigned) -1; @@ -184,7 +184,7 @@ Tk_DeleteErrorHandler( } else { prevPtr->nextPtr = nextPtr; } - ckfree((char *) errorPtr); + ckfree(errorPtr); continue; } prevPtr = errorPtr; diff --git a/generic/tkEvent.c b/generic/tkEvent.c index d22116a..24880a3 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -664,7 +664,7 @@ InvokeClientMessageHandlers( if (tmpPtr == NULL) { tsdPtr->lastCmPtr = prevPtr; } - (void) ckfree((char *) curPtr); + ckfree(curPtr); curPtr = tmpPtr; continue; } @@ -726,7 +726,7 @@ InvokeGenericHandlers( if (tmpPtr == NULL) { tsdPtr->lastGenericPtr = prevPtr; } - (void) ckfree((char *) curPtr); + ckfree(curPtr); curPtr = tmpPtr; continue; } @@ -790,7 +790,7 @@ Tk_CreateEventHandler( * No event handlers defined at all, so must create. */ - handlerPtr = (TkEventHandler *) ckalloc(sizeof(TkEventHandler)); + handlerPtr = ckalloc(sizeof(TkEventHandler)); winPtr->handlerList = handlerPtr; } else { int found = 0; @@ -821,8 +821,7 @@ Tk_CreateEventHandler( * No event handler matched, so create a new one. */ - handlerPtr->nextPtr = (TkEventHandler *) - ckalloc(sizeof(TkEventHandler)); + handlerPtr->nextPtr = ckalloc(sizeof(TkEventHandler)); handlerPtr = handlerPtr->nextPtr; } @@ -908,7 +907,7 @@ Tk_DeleteEventHandler( } else { prevPtr->nextPtr = handlerPtr->nextPtr; } - ckfree((char *) handlerPtr); + ckfree(handlerPtr); /* * No need to call XSelectInput: Tk always selects on all events for all @@ -944,7 +943,7 @@ Tk_CreateGenericHandler( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - handlerPtr = (GenericHandler *) ckalloc(sizeof(GenericHandler)); + handlerPtr = ckalloc(sizeof(GenericHandler)); handlerPtr->proc = proc; handlerPtr->clientData = clientData; @@ -1023,7 +1022,7 @@ Tk_CreateClientMessageHandler( * with an extra clientData field we'll never use. */ - handlerPtr = (GenericHandler *) ckalloc(sizeof(GenericHandler)); + handlerPtr = ckalloc(sizeof(GenericHandler)); handlerPtr->proc = (Tk_GenericProc *) proc; handlerPtr->clientData = NULL; /* never used */ @@ -1434,7 +1433,7 @@ TkEventDeadWindow( ipPtr->winPtr = None; } } - ckfree((char *) handlerPtr); + ckfree(handlerPtr); } } @@ -1609,7 +1608,7 @@ Tk_QueueWindowEvent( */ if (!(dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS)) { - wevPtr = (TkWindowEvent *) ckalloc(sizeof(TkWindowEvent)); + wevPtr = ckalloc(sizeof(TkWindowEvent)); wevPtr->header.proc = WindowEventProc; wevPtr->event = *eventPtr; Tcl_QueueEvent(&wevPtr->header, position); @@ -1641,7 +1640,7 @@ Tk_QueueWindowEvent( } } - wevPtr = (TkWindowEvent *) ckalloc(sizeof(TkWindowEvent)); + wevPtr = ckalloc(sizeof(TkWindowEvent)); wevPtr->header.proc = WindowEventProc; wevPtr->event = *eventPtr; if ((eventPtr->type == MotionNotify) && (position == TCL_QUEUE_TAIL)) { @@ -1862,7 +1861,7 @@ TkCreateExitHandler( { ExitHandler *exitPtr; - exitPtr = (ExitHandler *) ckalloc(sizeof(ExitHandler)); + exitPtr = ckalloc(sizeof(ExitHandler)); exitPtr->proc = proc; exitPtr->clientData = clientData; Tcl_MutexLock(&exitMutex); @@ -1927,7 +1926,7 @@ TkDeleteExitHandler( } else { prevPtr->nextPtr = exitPtr->nextPtr; } - ckfree((char *) exitPtr); + ckfree(exitPtr); break; } } @@ -1961,7 +1960,7 @@ TkCreateThreadExitHandler( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - exitPtr = (ExitHandler *) ckalloc(sizeof(ExitHandler)); + exitPtr = ckalloc(sizeof(ExitHandler)); exitPtr->proc = proc; exitPtr->clientData = clientData; @@ -2011,7 +2010,7 @@ TkDeleteThreadExitHandler( } else { prevPtr->nextPtr = exitPtr->nextPtr; } - ckfree((char *) exitPtr); + ckfree(exitPtr); return; } } @@ -2055,7 +2054,7 @@ TkFinalize( firstExitPtr = exitPtr->nextPtr; Tcl_MutexUnlock(&exitMutex); exitPtr->proc(exitPtr->clientData); - ckfree((char *) exitPtr); + ckfree(exitPtr); Tcl_MutexLock(&exitMutex); } firstExitPtr = NULL; @@ -2105,7 +2104,7 @@ TkFinalizeThread( tsdPtr->firstExitPtr = exitPtr->nextPtr; exitPtr->proc(exitPtr->clientData); - ckfree((char *) exitPtr); + ckfree(exitPtr); } } } diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c index b8e8101..170b0b7 100644 --- a/generic/tkFileFilter.c +++ b/generic/tkFileFilter.c @@ -303,7 +303,7 @@ AddClause( * Add the clause into the list of clauses */ - clausePtr = (FileFilterClause *) ckalloc(sizeof(FileFilterClause)); + clausePtr = ckalloc(sizeof(FileFilterClause)); clausePtr->patterns = NULL; clausePtr->patternsTail = NULL; clausePtr->macTypes = NULL; @@ -319,8 +319,7 @@ AddClause( if (globCount > 0 && globList != NULL) { for (i=0; i<globCount; i++) { - GlobPattern *globPtr = (GlobPattern *) - ckalloc(sizeof(GlobPattern)); + GlobPattern *globPtr = ckalloc(sizeof(GlobPattern)); int len; const char *str = Tcl_GetStringFromObj(globList[i], &len); @@ -330,12 +329,12 @@ AddClause( * Prepend a "*" to patterns that do not have a leading "*" */ - globPtr->pattern = ckalloc((unsigned) len+1); + globPtr->pattern = ckalloc(len + 1); globPtr->pattern[0] = '*'; strcpy(globPtr->pattern+1, str); } else if (isWindows) { if (strcmp(str, "*") == 0) { - globPtr->pattern = ckalloc(4 * sizeof(char)); + globPtr->pattern = ckalloc(4); strcpy(globPtr->pattern, "*.*"); } else if (strcmp(str, "") == 0) { /* @@ -344,14 +343,14 @@ AddClause( * TODO: "*." actually matches with all files on Win95 */ - globPtr->pattern = ckalloc(3 * sizeof(char)); + globPtr->pattern = ckalloc(3); strcpy(globPtr->pattern, "*."); } else { - globPtr->pattern = ckalloc((unsigned) len); + globPtr->pattern = ckalloc(len); strcpy(globPtr->pattern, str); } } else { - globPtr->pattern = ckalloc((unsigned) len); + globPtr->pattern = ckalloc(len); strcpy(globPtr->pattern, str); } @@ -375,7 +374,7 @@ AddClause( for (i=0; i<ostypeCount; i++) { Tcl_DString osTypeDS; int len; - MacFileType *mfPtr = (MacFileType *) ckalloc(sizeof(MacFileType)); + MacFileType *mfPtr = ckalloc(sizeof(MacFileType)); const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len); char *string; @@ -444,11 +443,11 @@ GetFilter( } } - filterPtr = (FileFilter *) ckalloc(sizeof(FileFilter)); + filterPtr = ckalloc(sizeof(FileFilter)); filterPtr->clauses = NULL; filterPtr->clausesTail = NULL; len = strlen(name) + 1; - filterPtr->name = ckalloc((unsigned) len); + filterPtr->name = ckalloc(len); memcpy(filterPtr->name, name, len); if (flistPtr->filters == NULL) { diff --git a/generic/tkFocus.c b/generic/tkFocus.c index 622867c..17482aa 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -418,7 +418,7 @@ TkFocusFilterEvent( } } if (tlFocusPtr == NULL) { - tlFocusPtr = (ToplevelFocusInfo *) ckalloc(sizeof(ToplevelFocusInfo)); + tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); tlFocusPtr->topLevelPtr = tlFocusPtr->focusWinPtr = winPtr; tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tlFocusPtr; @@ -611,7 +611,7 @@ TkSetFocusWin( } } if (tlFocusPtr == NULL) { - tlFocusPtr = (ToplevelFocusInfo *) ckalloc(sizeof(ToplevelFocusInfo)); + tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); tlFocusPtr->topLevelPtr = topLevelPtr; tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tlFocusPtr; @@ -837,7 +837,7 @@ TkFocusDeadWindow( } else { prevPtr->nextPtr = tlFocusPtr->nextPtr; } - ckfree((char *) tlFocusPtr); + ckfree(tlFocusPtr); break; } else if (winPtr == tlFocusPtr->focusWinPtr) { /* @@ -997,7 +997,7 @@ FindDisplayFocusInfo( * The record doesn't exist yet. Make a new one. */ - displayFocusPtr = (DisplayFocusInfo *) ckalloc(sizeof(DisplayFocusInfo)); + displayFocusPtr = ckalloc(sizeof(DisplayFocusInfo)); displayFocusPtr->dispPtr = dispPtr; displayFocusPtr->focusWinPtr = NULL; displayFocusPtr->focusOnMapPtr = NULL; @@ -1033,13 +1033,13 @@ TkFocusFree( DisplayFocusInfo *displayFocusPtr = mainPtr->displayFocusPtr; mainPtr->displayFocusPtr = mainPtr->displayFocusPtr->nextPtr; - ckfree((char *) displayFocusPtr); + ckfree(displayFocusPtr); } while (mainPtr->tlFocusPtr != NULL) { ToplevelFocusInfo *tlFocusPtr = mainPtr->tlFocusPtr; mainPtr->tlFocusPtr = mainPtr->tlFocusPtr->nextPtr; - ckfree((char *) tlFocusPtr); + ckfree(tlFocusPtr); } } @@ -1126,8 +1126,7 @@ TkFocusSplit( * Move focus to new toplevel. */ - ToplevelFocusInfo *newTlFocusPtr = (ToplevelFocusInfo *) - ckalloc(sizeof(ToplevelFocusInfo)); + ToplevelFocusInfo *newTlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); newTlFocusPtr->topLevelPtr = winPtr; newTlFocusPtr->focusWinPtr = tlFocusPtr->focusWinPtr; @@ -1176,7 +1175,7 @@ TkFocusJoin( && winPtr->mainPtr->tlFocusPtr->topLevelPtr == winPtr) { tmpPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tmpPtr->nextPtr; - ckfree((char *)tmpPtr); + ckfree(tmpPtr); } else if (winPtr && winPtr->mainPtr) { for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { @@ -1184,7 +1183,7 @@ TkFocusJoin( tlFocusPtr->nextPtr->topLevelPtr == winPtr) { tmpPtr = tlFocusPtr->nextPtr; tlFocusPtr->nextPtr = tmpPtr->nextPtr; - ckfree((char *)tmpPtr); + ckfree(tmpPtr); break; } } diff --git a/generic/tkFont.c b/generic/tkFont.c index b768bbd..06bc0f1 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -379,7 +379,7 @@ void TkFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - TkFontInfo *fiPtr = (TkFontInfo *) ckalloc(sizeof(TkFontInfo)); + TkFontInfo *fiPtr = ckalloc(sizeof(TkFontInfo)); Tcl_InitHashTable(&fiPtr->fontCache, TCL_STRING_KEYS); Tcl_InitHashTable(&fiPtr->namedTable, TCL_STRING_KEYS); @@ -444,7 +444,7 @@ TkFontPkgFree( if (fiPtr->updatePending != 0) { Tcl_CancelIdleCall(TheWorldHasChanged, fiPtr); } - ckfree((char *) fiPtr); + ckfree(fiPtr); } /* @@ -969,7 +969,7 @@ TkCreateNamedFont( return TCL_OK; } - nfPtr = (NamedFont *) ckalloc(sizeof(NamedFont)); + nfPtr = ckalloc(sizeof(NamedFont)); nfPtr->deletePending = 0; Tcl_SetHashValue(namedHashPtr, nfPtr); nfPtr->fa = *faPtr; @@ -1012,7 +1012,7 @@ TkDeleteNamedFont( nfPtr->deletePending = 1; } else { Tcl_DeleteHashEntry(namedHashPtr); - ckfree((char *) nfPtr); + ckfree(nfPtr); } return TCL_OK; } @@ -1425,7 +1425,7 @@ Tk_FreeFont( nfPtr->refCount--; if ((nfPtr->refCount == 0) && (nfPtr->deletePending != 0)) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); - ckfree((char *) nfPtr); + ckfree(nfPtr); } } @@ -1445,7 +1445,7 @@ Tk_FreeFont( TkpDeleteFont(fontPtr); if (fontPtr->objRefCount == 0) { - ckfree((char *) fontPtr); + ckfree(fontPtr); } } @@ -1512,7 +1512,7 @@ FreeFontObj( if (fontPtr != NULL) { fontPtr->objRefCount--; if ((fontPtr->resourceRefCount == 0) && (fontPtr->objRefCount == 0)) { - ckfree((char *) fontPtr); + ckfree(fontPtr); objPtr->internalRep.twoPtrValue.ptr1 = NULL; } } @@ -1974,8 +1974,8 @@ Tk_ComputeTextLayout( maxChunks = 1; - layoutPtr = (TextLayout *) - ckalloc(sizeof(TextLayout) + (maxChunks-1) * sizeof(LayoutChunk)); + layoutPtr = ckalloc(sizeof(TextLayout) + + (maxChunks-1) * sizeof(LayoutChunk)); layoutPtr->tkfont = tkfont; layoutPtr->string = string; layoutPtr->numChunks = 0; @@ -2231,7 +2231,7 @@ Tk_FreeTextLayout( TextLayout *layoutPtr = (TextLayout *) textLayout; if (layoutPtr != NULL) { - ckfree((char *) layoutPtr); + ckfree(layoutPtr); } } @@ -3745,7 +3745,7 @@ NewChunk( if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk)); - layoutPtr = (TextLayout *) ckrealloc((char *) layoutPtr, s); + layoutPtr = ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; *maxPtr = maxChunks; diff --git a/generic/tkFrame.c b/generic/tkFrame.c index eaccd58..e64ee29 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -429,7 +429,7 @@ TkCreateFrame( * application. */ { int result, i; - Tcl_Obj **objv = (Tcl_Obj **) ckalloc((argc+1) * sizeof(Tcl_Obj **)); + Tcl_Obj **objv = ckalloc((argc+1) * sizeof(Tcl_Obj **)); for (i=0; i<argc; i++) { objv[i] = Tcl_NewStringObj(argv[i], -1); @@ -441,7 +441,7 @@ TkCreateFrame( for (i=0; i<argc; i++) { Tcl_DecrRefCount(objv[i]); } - ckfree((char *) objv); + ckfree(objv); return result; } @@ -622,10 +622,10 @@ CreateFrame( */ if (type == TYPE_LABELFRAME) { - framePtr = (Frame *) ckalloc(sizeof(Labelframe)); + framePtr = ckalloc(sizeof(Labelframe)); memset(framePtr, 0, sizeof(Labelframe)); } else { - framePtr = (Frame *) ckalloc(sizeof(Frame)); + framePtr = ckalloc(sizeof(Frame)); memset(framePtr, 0, sizeof(Frame)); } framePtr->tkwin = newWin; @@ -846,7 +846,7 @@ DestroyFrame( if (framePtr->colormap != None) { Tk_FreeColormap(framePtr->display, framePtr->colormap); } - ckfree((char *) framePtr); + ckfree(framePtr); } /* diff --git a/generic/tkGC.c b/generic/tkGC.c index 07f6014..0fa55a3 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -230,7 +230,7 @@ Tk_GetGC( * and add a new structure to the database. */ - gcPtr = (TkGC *) ckalloc(sizeof(TkGC)); + gcPtr = ckalloc(sizeof(TkGC)); /* * Find or make a drawable to use to specify the screen and depth of the @@ -320,7 +320,7 @@ Tk_FreeGC( XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(idHashPtr); - ckfree((char *) gcPtr); + ckfree(gcPtr); } } @@ -362,7 +362,7 @@ TkGCCleanup( XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(entryPtr); - ckfree((char *) gcPtr); + ckfree(gcPtr); } Tcl_DeleteHashTable(&dispPtr->gcValueTable); Tcl_DeleteHashTable(&dispPtr->gcIdTable); diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c index 2a9e2f4..bcfdcf5 100644 --- a/generic/tkGeometry.c +++ b/generic/tkGeometry.c @@ -462,7 +462,7 @@ Tk_MaintainGeometry( if (!isNew) { masterPtr = Tcl_GetHashValue(hPtr); } else { - masterPtr = (MaintainMaster *) ckalloc(sizeof(MaintainMaster)); + masterPtr = ckalloc(sizeof(MaintainMaster)); masterPtr->ancestor = master; masterPtr->checkScheduled = 0; masterPtr->slavePtr = NULL; @@ -480,7 +480,7 @@ Tk_MaintainGeometry( goto gotSlave; } } - slavePtr = (MaintainSlave *) ckalloc(sizeof(MaintainSlave)); + slavePtr = ckalloc(sizeof(MaintainSlave)); slavePtr->slave = slave; slavePtr->master = master; slavePtr->nextPtr = masterPtr->slavePtr; @@ -608,7 +608,7 @@ Tk_UnmaintainGeometry( } Tk_DeleteEventHandler(slavePtr->slave, StructureNotifyMask, MaintainSlaveProc, slavePtr); - ckfree((char *) slavePtr); + ckfree(slavePtr); if (masterPtr->slavePtr == NULL) { if (masterPtr->ancestor != NULL) { for (ancestor = master; ; ancestor = Tk_Parent(ancestor)) { @@ -623,7 +623,7 @@ Tk_UnmaintainGeometry( Tcl_CancelIdleCall(MaintainCheckProc, masterPtr); } Tcl_DeleteHashEntry(hPtr); - ckfree((char *) masterPtr); + ckfree(masterPtr); } } diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 8056b2c..a72fb0c 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -1338,7 +1338,7 @@ QueueGrabWindowChange( { NewGrabWinEvent *grabEvPtr; - grabEvPtr = (NewGrabWinEvent *) ckalloc(sizeof(NewGrabWinEvent)); + grabEvPtr = ckalloc(sizeof(NewGrabWinEvent)); grabEvPtr->header.proc = GrabWinEventProc; grabEvPtr->dispPtr = dispPtr; if (grabWinPtr == NULL) { diff --git a/generic/tkGrid.c b/generic/tkGrid.c index b5a439a..5014dad 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1926,8 +1926,7 @@ ResolveConstraints( gridCount = MAX(constraintCount, slotCount); if (gridCount >= TYPICAL_SIZE) { - layoutPtr = (GridLayout *) - ckalloc(sizeof(GridLayout) * (1+gridCount)); + layoutPtr = ckalloc(sizeof(GridLayout) * (1+gridCount)); } else { layoutPtr = layoutData; } @@ -2049,12 +2048,12 @@ ResolveConstraints( * sizeof(UniformGroup); size_t newSize = (uniformGroupsAlloced + UNIFORM_PREALLOC) * sizeof(UniformGroup); - UniformGroup *newUG = (UniformGroup *) ckalloc(newSize); + UniformGroup *newUG = ckalloc(newSize); UniformGroup *oldUG = uniformGroupPtr; memcpy(newUG, oldUG, oldSize); if (oldUG != uniformPre) { - ckfree((char *) oldUG); + ckfree(oldUG); } uniformGroupPtr = newUG; uniformGroupsAlloced += UNIFORM_PREALLOC; @@ -2094,7 +2093,7 @@ ResolveConstraints( } if (uniformGroupPtr != uniformPre) { - ckfree((char *) uniformGroupPtr); + ckfree(uniformGroupPtr); } /* @@ -2364,7 +2363,7 @@ ResolveConstraints( --layoutPtr; if (layoutPtr != layoutData) { - ckfree((char *) layoutPtr); + ckfree(layoutPtr); } return requiredSize; } @@ -2412,7 +2411,7 @@ GetGrid( if (!isNew) { return Tcl_GetHashValue(hPtr); } - gridPtr = (Gridder *) ckalloc(sizeof(Gridder)); + gridPtr = ckalloc(sizeof(Gridder)); gridPtr->tkwin = tkwin; gridPtr->masterPtr = NULL; gridPtr->masterDataPtr = NULL; @@ -2619,14 +2618,14 @@ CheckSlotData( int newNumSlot = slot + PREALLOC; size_t oldSize = numSlot * sizeof(SlotInfo); size_t newSize = newNumSlot * sizeof(SlotInfo); - SlotInfo *newSI = (SlotInfo *) ckalloc(newSize); + SlotInfo *newSI = ckalloc(newSize); SlotInfo *oldSI = (slotType == ROW) ? masterPtr->masterDataPtr->rowPtr : masterPtr->masterDataPtr->columnPtr; memcpy(newSI, oldSI, oldSize); memset(newSI+numSlot, 0, newSize - oldSize); - ckfree((char *) oldSI); + ckfree(oldSI); if (slotType == ROW) { masterPtr->masterDataPtr->rowPtr = newSI; masterPtr->masterDataPtr->rowSpace = newNumSlot; @@ -2669,17 +2668,17 @@ InitMasterData( Gridder *masterPtr) { if (masterPtr->masterDataPtr == NULL) { - GridMaster *gridPtr = masterPtr->masterDataPtr = (GridMaster *) + GridMaster *gridPtr = masterPtr->masterDataPtr = ckalloc(sizeof(GridMaster)); size_t size = sizeof(SlotInfo) * TYPICAL_SIZE; gridPtr->columnEnd = 0; gridPtr->columnMax = 0; - gridPtr->columnPtr = (SlotInfo *) ckalloc(size); + gridPtr->columnPtr = ckalloc(size); gridPtr->columnSpace = TYPICAL_SIZE; gridPtr->rowEnd = 0; gridPtr->rowMax = 0; - gridPtr->rowPtr = (SlotInfo *) ckalloc(size); + gridPtr->rowPtr = ckalloc(size); gridPtr->rowSpace = TYPICAL_SIZE; gridPtr->startX = 0; gridPtr->startY = 0; @@ -2781,14 +2780,14 @@ DestroyGrid( if (gridPtr->masterDataPtr != NULL) { if (gridPtr->masterDataPtr->rowPtr != NULL) { - ckfree((char *) gridPtr->masterDataPtr -> rowPtr); + ckfree(gridPtr->masterDataPtr -> rowPtr); } if (gridPtr->masterDataPtr->columnPtr != NULL) { - ckfree((char *) gridPtr->masterDataPtr -> columnPtr); + ckfree(gridPtr->masterDataPtr -> columnPtr); } - ckfree((char *) gridPtr->masterDataPtr); + ckfree(gridPtr->masterDataPtr); } - ckfree((char *) gridPtr); + ckfree(gridPtr); } /* diff --git a/generic/tkImage.c b/generic/tkImage.c index ca818a3..31a2fa3 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -115,12 +115,12 @@ ImageTypeThreadExitProc( while (tsdPtr->oldImageTypeList != NULL) { freePtr = tsdPtr->oldImageTypeList; tsdPtr->oldImageTypeList = tsdPtr->oldImageTypeList->nextPtr; - ckfree((char *) freePtr); + ckfree(freePtr); } while (tsdPtr->imageTypeList != NULL) { freePtr = tsdPtr->imageTypeList; tsdPtr->imageTypeList = tsdPtr->imageTypeList->nextPtr; - ckfree((char *) freePtr); + ckfree(freePtr); } } @@ -158,7 +158,7 @@ Tk_CreateOldImageType( tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL); } - copyPtr = (Tk_ImageType *) ckalloc(sizeof(Tk_ImageType)); + copyPtr = ckalloc(sizeof(Tk_ImageType)); *copyPtr = *typePtr; copyPtr->nextPtr = tsdPtr->oldImageTypeList; tsdPtr->oldImageTypeList = copyPtr; @@ -179,7 +179,7 @@ Tk_CreateImageType( tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL); } - copyPtr = (Tk_ImageType *) ckalloc(sizeof(Tk_ImageType)); + copyPtr = ckalloc(sizeof(Tk_ImageType)); *copyPtr = *typePtr; copyPtr->nextPtr = tsdPtr->imageTypeList; tsdPtr->imageTypeList = copyPtr; @@ -318,7 +318,7 @@ Tk_ImageObjCmd( hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew); if (isNew) { - masterPtr = (ImageMaster *) ckalloc(sizeof(ImageMaster)); + masterPtr = ckalloc(sizeof(ImageMaster)); masterPtr->typePtr = NULL; masterPtr->masterData = NULL; masterPtr->width = masterPtr->height = 1; @@ -363,7 +363,7 @@ Tk_ImageObjCmd( if (oldimage) { int i; - args = (Tcl_Obj **) ckalloc((objc+1) * sizeof(char *)); + args = ckalloc((objc+1) * sizeof(char *)); for (i = 0; i < objc; i++) { args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]); } @@ -375,13 +375,13 @@ Tk_ImageObjCmd( EventuallyDeleteImage(masterPtr, 0); Tcl_Release(masterPtr); if (oldimage) { - ckfree((char *) args); + ckfree(args); } return TCL_ERROR; } Tcl_Release(masterPtr); if (oldimage) { - ckfree((char *) args); + ckfree(args); } masterPtr->typePtr = typePtr; for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; @@ -618,7 +618,7 @@ Tk_GetImage( if (masterPtr->deleted) { goto noSuchImage; } - imagePtr = (Image *) ckalloc(sizeof(Image)); + imagePtr = ckalloc(sizeof(Image)); imagePtr->tkwin = tkwin; imagePtr->display = Tk_Display(tkwin); imagePtr->masterPtr = masterPtr; @@ -681,7 +681,7 @@ Tk_FreeImage( } prevPtr->nextPtr = imagePtr->nextPtr; } - ckfree((char *) imagePtr); + ckfree(imagePtr); /* * If there are no more instances left for the master, and if the master @@ -693,7 +693,7 @@ Tk_FreeImage( Tcl_DeleteHashEntry(masterPtr->hPtr); } Tcl_Release(masterPtr->winPtr); - ckfree((char *) masterPtr); + ckfree(masterPtr); } } @@ -970,7 +970,7 @@ DeleteImage( Tcl_DeleteHashEntry(masterPtr->hPtr); } Tcl_Release(masterPtr->winPtr); - ckfree((char *) masterPtr); + ckfree(masterPtr); } else { masterPtr->deleted = 1; } diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 32eb536..1f06b7d 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -186,9 +186,8 @@ ImgBmapCreate( ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - BitmapMaster *masterPtr; + BitmapMaster *masterPtr = ckalloc(sizeof(BitmapMaster)); - masterPtr = (BitmapMaster *) ckalloc(sizeof(BitmapMaster)); masterPtr->tkMaster = master; masterPtr->interp = interp; masterPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgBmapCmd, @@ -242,8 +241,8 @@ ImgBmapConfigureMaster( { BitmapInstance *instancePtr; int maskWidth, maskHeight, dummy1, dummy2; + const char **argv = ckalloc((objc+1) * sizeof(char *)); - const char **argv = (const char **) ckalloc((objc+1) * sizeof(char *)); for (dummy1 = 0; dummy1 < objc; dummy1++) { argv[dummy1]=Tcl_GetString(objv[dummy1]); } @@ -251,10 +250,10 @@ ImgBmapConfigureMaster( if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp), configSpecs, objc, argv, (char *) masterPtr, flags) != TCL_OK) { - ckfree((char *) argv); + ckfree(argv); return TCL_ERROR; } - ckfree((char *) argv); + ckfree(argv); /* * Parse the bitmap and/or mask to create binary data. Make sure that the @@ -613,7 +612,7 @@ TkGetBitmapData( goto error; } numBytes = ((width+7)/8) * height; - data = ckalloc((unsigned) numBytes); + data = ckalloc(numBytes); for (p = data; numBytes > 0; p++, numBytes--) { if (NextBitmapWord(&pi) != TCL_OK) { goto error; @@ -831,7 +830,7 @@ ImgBmapGet( * the image. */ - instancePtr = (BitmapInstance *) ckalloc(sizeof(BitmapInstance)); + instancePtr = ckalloc(sizeof(BitmapInstance)); instancePtr->refCount = 1; instancePtr->masterPtr = masterPtr; instancePtr->tkwin = tkwin; @@ -976,7 +975,7 @@ ImgBmapFree( } prevPtr->nextPtr = instancePtr->nextPtr; } - ckfree((char *) instancePtr); + ckfree(instancePtr); } /* @@ -1017,7 +1016,7 @@ ImgBmapDelete( ckfree(masterPtr->maskData); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); - ckfree((char *) masterPtr); + ckfree(masterPtr); } /* diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 0ece066..05dc109 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -574,7 +574,7 @@ FileReadGIF( if (trashBuffer == NULL) { nBytes = fileWidth * fileHeight * 3; - trashBuffer = (unsigned char *) ckalloc((unsigned) nBytes); + trashBuffer = ckalloc(nBytes); } /* @@ -658,20 +658,20 @@ FileReadGIF( block.offset[3] = (transparent>=0) ? 3 : 0; block.pitch = block.pixelSize * imageWidth; nBytes = block.pitch * imageHeight; - block.pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes); + block.pixelPtr = ckalloc(nBytes); if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth, imageHeight, colorMap, srcX, srcY, BitSet(buf[8],INTERLACE), transparent) != TCL_OK) { - ckfree((char *) block.pixelPtr); + ckfree(block.pixelPtr); goto error; } if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { - ckfree((char *) block.pixelPtr); + ckfree(block.pixelPtr); goto error; } - ckfree((char *) block.pixelPtr); + ckfree(block.pixelPtr); } /* @@ -688,7 +688,7 @@ FileReadGIF( */ if (trashBuffer != NULL) { - ckfree((char *) trashBuffer); + ckfree(trashBuffer); } return result; } diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index ec84a1c..b71faed 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -388,7 +388,7 @@ CleanupPNGImage( } if (pngPtr->block.pixelPtr) { - ckfree((char *) pngPtr->block.pixelPtr); + ckfree(pngPtr->block.pixelPtr); } if (pngPtr->thisLineObj) { Tcl_DecrRefCount(pngPtr->thisLineObj); @@ -2449,8 +2449,7 @@ DecodePNG( pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); - pngPtr->block.pixelPtr = (unsigned char *) - attemptckalloc(pngPtr->blockLen); + pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen); if (!pngPtr->block.pixelPtr) { Tcl_SetResult(interp, "Memory allocation failed", TCL_STATIC); return TCL_ERROR; diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index 88f0858..71f4481 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -210,7 +210,7 @@ FileReadPPM( nLines = 1; } nBytes = nLines * block.pitch; - pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes); + pixelPtr = ckalloc(nBytes); block.pixelPtr = pixelPtr + srcX * block.pixelSize; for (h = height; h > 0; h -= nLines) { @@ -224,7 +224,7 @@ FileReadPPM( fileName, "\": ", Tcl_Eof(chan) ? "not enough data" : Tcl_PosixError(interp), NULL); - ckfree((char *) pixelPtr); + ckfree(pixelPtr); return TCL_ERROR; } if (maxIntensity != 255) { @@ -237,13 +237,13 @@ FileReadPPM( block.height = nLines; if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { - ckfree((char *) pixelPtr); + ckfree(pixelPtr); return TCL_ERROR; } destY += nLines; } - ckfree((char *) pixelPtr); + ckfree(pixelPtr); return TCL_OK; } @@ -562,7 +562,7 @@ StringReadPPM( nLines = 1; } nBytes = nLines * block.pitch; - pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes); + pixelPtr = ckalloc(nBytes); block.pixelPtr = pixelPtr + srcX * block.pixelSize; for (h = height; h > 0; h -= nLines) { @@ -573,7 +573,7 @@ StringReadPPM( nBytes = nLines * block.pitch; } if (dataSize < nBytes) { - ckfree((char *) pixelPtr); + ckfree(pixelPtr); Tcl_AppendResult(interp, "truncated PPM data", NULL); return TCL_ERROR; } @@ -584,13 +584,13 @@ StringReadPPM( block.height = nLines; if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { - ckfree((char *) pixelPtr); + ckfree(pixelPtr); return TCL_ERROR; } destY += nLines; } - ckfree((char *) pixelPtr); + ckfree(pixelPtr); return TCL_OK; } diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index df33769..5084e55 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -275,7 +275,7 @@ TkImgPhotoGet( * a new instance of the image. */ - instancePtr = (PhotoInstance *) ckalloc(sizeof(PhotoInstance)); + instancePtr = ckalloc(sizeof(PhotoInstance)); instancePtr->masterPtr = masterPtr; instancePtr->display = Tk_Display(tkwin); instancePtr->colormap = Tk_Colormap(tkwin); @@ -798,8 +798,8 @@ TkImgPhotoInstanceSetSize( * such possibility. */ - newError = (schar *) ckalloc((unsigned) - masterPtr->height * masterPtr->width * 3 * sizeof(schar)); + newError = ckalloc(masterPtr->height * masterPtr->width + * 3 * sizeof(schar)); /* * Zero the new array so that we don't get bogus error values @@ -852,7 +852,7 @@ TkImgPhotoInstanceSetSize( errSrcPtr += instancePtr->width * 3; } } - ckfree((char *) instancePtr->error); + ckfree(instancePtr->error); } instancePtr->error = newError; @@ -1033,7 +1033,7 @@ GetColorTable( * No color table currently available; need to make one. */ - colorPtr = (ColorTable *) ckalloc(sizeof(ColorTable)); + colorPtr = ckalloc(sizeof(ColorTable)); /* * The following line of code should not normally be needed due to the @@ -1196,7 +1196,7 @@ AllocateColors( } else { numColors = MAX(MAX(nRed, nGreen), nBlue); } - colors = (XColor *) ckalloc(numColors * sizeof(XColor)); + colors = ckalloc(numColors * sizeof(XColor)); for (i = 0; i < numColors; ++i) { if (igam == 1.0) { @@ -1216,7 +1216,7 @@ AllocateColors( */ numColors = (mono) ? nRed: (nRed * nGreen * nBlue); - colors = (XColor *) ckalloc(numColors * sizeof(XColor)); + colors = ckalloc(numColors * sizeof(XColor)); if (!mono) { /* @@ -1260,7 +1260,7 @@ AllocateColors( * Now try to allocate the colors we've calculated. */ - pixels = (unsigned long *) ckalloc(numColors * sizeof(unsigned long)); + pixels = ckalloc(numColors * sizeof(unsigned long)); for (i = 0; i < numColors; ++i) { if (!XAllocColor(colorPtr->id.display, colorPtr->id.colormap, &colors[i])) { @@ -1291,8 +1291,8 @@ AllocateColors( break; } XFreeColors(colorPtr->id.display, colorPtr->id.colormap, pixels, i, 0); - ckfree((char *) colors); - ckfree((char *) pixels); + ckfree(colors); + ckfree(pixels); if (!mono) { if ((nRed == 2) && (nGreen == 2) && (nBlue == 2)) { @@ -1394,7 +1394,7 @@ AllocateColors( } } - ckfree((char *) colors); + ckfree(colors); } /* @@ -1429,7 +1429,7 @@ DisposeColorTable( colorPtr->pixelMap, colorPtr->numColors, 0); Tk_FreeColormap(colorPtr->id.display, colorPtr->id.colormap); } - ckfree((char *) colorPtr->pixelMap); + ckfree(colorPtr->pixelMap); } entry = Tcl_FindHashEntry(&imgPhotoColorHash, (char *) &colorPtr->id); @@ -1438,7 +1438,7 @@ DisposeColorTable( } Tcl_DeleteHashEntry(entry); - ckfree((char *) colorPtr); + ckfree(colorPtr); } /* @@ -1523,7 +1523,7 @@ ReclaimColors( colorPtr->pixelMap, colorPtr->numColors, 0); numColors -= colorPtr->numColors; colorPtr->numColors = 0; - ckfree((char *) colorPtr->pixelMap); + ckfree(colorPtr->pixelMap); colorPtr->pixelMap = NULL; } @@ -1567,7 +1567,7 @@ TkImgDisposeInstance( XDestroyImage(instancePtr->imagePtr); } if (instancePtr->error != NULL) { - ckfree((char *) instancePtr->error); + ckfree(instancePtr->error); } if (instancePtr->colorTablePtr != NULL) { FreeColorTable(instancePtr->colorTablePtr, 1); @@ -1583,7 +1583,7 @@ TkImgDisposeInstance( prevPtr->nextPtr = instancePtr->nextPtr; } Tk_FreeColormap(instancePtr->display, instancePtr->colormap); - ckfree((char *) instancePtr); + ckfree(instancePtr); } /* @@ -1664,8 +1664,7 @@ TkImgDitherInstance( * recovering from the failure. */ - imagePtr->data = - ckalloc((unsigned) (imagePtr->bytes_per_line * nLines)); + imagePtr->data = ckalloc(imagePtr->bytes_per_line * nLines); bigEndian = imagePtr->bitmap_bit_order == MSBFirst; firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1; diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 589b9b8..0ad0738 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -227,13 +227,13 @@ PhotoFormatThreadExitProc( while (tsdPtr->oldFormatList != NULL) { freePtr = tsdPtr->oldFormatList; tsdPtr->oldFormatList = tsdPtr->oldFormatList->nextPtr; - ckfree((char *) freePtr); + ckfree(freePtr); } while (tsdPtr->formatList != NULL) { freePtr = tsdPtr->formatList; tsdPtr->formatList = tsdPtr->formatList->nextPtr; - ckfree((char *) freePtr->name); - ckfree((char *) freePtr); + ckfree(freePtr->name); + ckfree(freePtr); } } @@ -271,7 +271,7 @@ Tk_CreateOldPhotoImageFormat( tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL); } - copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat)); + copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat)); *copyPtr = *formatPtr; copyPtr->nextPtr = tsdPtr->oldFormatList; tsdPtr->oldFormatList = copyPtr; @@ -292,7 +292,7 @@ Tk_CreatePhotoImageFormat( tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL); } - copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat)); + copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat)); *copyPtr = *formatPtr; if (isupper((unsigned char) *formatPtr->name)) { copyPtr->nextPtr = tsdPtr->oldFormatList; @@ -344,7 +344,7 @@ ImgPhotoCreate( * Allocate and initialize the photo image master record. */ - masterPtr = (PhotoMaster *) ckalloc(sizeof(PhotoMaster)); + masterPtr = ckalloc(sizeof(PhotoMaster)); memset(masterPtr, 0, sizeof(PhotoMaster)); masterPtr->tkMaster = master; masterPtr->interp = interp; @@ -875,8 +875,7 @@ ImgPhotoCmd( break; } dataWidth = listObjc; - pixelPtr = (unsigned char *) - ckalloc((unsigned) dataWidth * dataHeight * 3); + pixelPtr = ckalloc(dataWidth * dataHeight * 3); block.pixelPtr = pixelPtr; } else if (listObjc != dataWidth) { Tcl_AppendResult(interp, "all elements of color list must", @@ -937,7 +936,7 @@ ImgPhotoCmd( } if (y < dataHeight || dataHeight == 0 || dataWidth == 0) { if (block.pixelPtr != NULL) { - ckfree((char *) block.pixelPtr); + ckfree(block.pixelPtr); } if (y < dataHeight) { return TCL_ERROR; @@ -966,7 +965,7 @@ ImgPhotoCmd( options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, TK_PHOTO_COMPOSITE_SET); - ckfree((char *) block.pixelPtr); + ckfree(block.pixelPtr); return result; case PHOTO_READ: { @@ -1722,7 +1721,7 @@ ImgPhotoConfigureMaster( Tk_PhotoImageFormat *imageFormat; const char **args; - args = (const char **) ckalloc((objc + 1) * sizeof(char *)); + args = ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { args[j] = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (args[j][0] == '-')) { @@ -1732,7 +1731,7 @@ ImgPhotoConfigureMaster( data = objv[i]; j--; } else { - ckfree((char *) args); + ckfree(args); Tcl_AppendResult(interp, "value for \"-data\" missing", NULL); return TCL_ERROR; @@ -1743,7 +1742,7 @@ ImgPhotoConfigureMaster( format = objv[i]; j--; } else { - ckfree((char *) args); + ckfree(args); Tcl_AppendResult(interp, "value for \"-format\" missing", NULL); return TCL_ERROR; @@ -1781,10 +1780,10 @@ ImgPhotoConfigureMaster( if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs, j, args, (char *) masterPtr, flags) != TCL_OK) { - ckfree((char *) args); + ckfree(args); goto errorExit; } - ckfree((char *) args); + ckfree(args); /* * Regard the empty string for -file, -data or -format as the null value. @@ -2064,7 +2063,7 @@ ImgPhotoDelete( Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd); } if (masterPtr->pix32 != NULL) { - ckfree((char *) masterPtr->pix32); + ckfree(masterPtr->pix32); } if (masterPtr->validRegion != NULL) { TkDestroyRegion(masterPtr->validRegion); @@ -2076,7 +2075,7 @@ ImgPhotoDelete( Tcl_DecrRefCount(masterPtr->format); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); - ckfree((char *) masterPtr); + ckfree(masterPtr); } /* @@ -2169,7 +2168,7 @@ ImgPhotoSetSize( if (newPixSize == 0) { newPix32 = NULL; } else { - newPix32 = (unsigned char *) attemptckalloc(newPixSize); + newPix32 = attemptckalloc(newPixSize); if (newPix32 == NULL) { return TCL_ERROR; } @@ -2253,7 +2252,7 @@ ImgPhotoSetSize( } } - ckfree((char *) masterPtr->pix32); + ckfree(masterPtr->pix32); } masterPtr->pix32 = newPix32; @@ -3631,8 +3630,7 @@ ImgGetPhoto( if ((greenOffset||blueOffset) && !(optPtr->options & OPT_GRAYSCALE)) { newPixelSize += 2; } - data = attemptckalloc((unsigned int) (newPixelSize * - blockPtr->width * blockPtr->height)); + data = attemptckalloc(newPixelSize*blockPtr->width*blockPtr->height); if (data == NULL) { return NULL; } @@ -3773,7 +3771,7 @@ ImgStringWrite( Tcl_DStringInit(&data); if ((blockPtr->width > 0) && (blockPtr->height > 0)) { - char *line = ckalloc((unsigned) ((8 * blockPtr->width) + 2)); + char *line = ckalloc((8 * blockPtr->width) + 2); int row, col; for (row=0; row<blockPtr->height; row++) { diff --git a/generic/tkImgUtil.c b/generic/tkImgUtil.c index 577efbc..8752b2e 100644 --- a/generic/tkImgUtil.c +++ b/generic/tkImgUtil.c @@ -57,7 +57,7 @@ TkAlignImageData( dataWidth += (alignment - (dataWidth % alignment)); } - data = ckalloc((unsigned) dataWidth * image->height); + data = ckalloc(dataWidth * image->height); destPtr = data; for (i = 0; i < image->height; i++) { diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 57f4c74..b035878 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -491,8 +491,7 @@ Tk_ListboxObjCmd( * command, so future invocations will have access to it. */ - optionTables = (ListboxOptionTables *) - ckalloc(sizeof(ListboxOptionTables)); + optionTables = ckalloc(sizeof(ListboxOptionTables)); /* * Set up an exit handler to free the optionTables struct. @@ -517,7 +516,7 @@ Tk_ListboxObjCmd( * already (e.g. resource pointers). */ - listPtr = (Listbox *) ckalloc(sizeof(Listbox)); + listPtr = ckalloc(sizeof(Listbox)); memset(listPtr, 0, (sizeof(Listbox))); listPtr->tkwin = tkwin; @@ -528,11 +527,9 @@ Tk_ListboxObjCmd( ListboxCmdDeletedProc); listPtr->optionTable = optionTables->listboxOptionTable; listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable; - listPtr->selection = (Tcl_HashTable *) - ckalloc(sizeof(Tcl_HashTable)); + listPtr->selection = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS); - listPtr->itemAttrTable = (Tcl_HashTable *) - ckalloc(sizeof(Tcl_HashTable)); + listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS); listPtr->relief = TK_RELIEF_RAISED; listPtr->textGC = None; @@ -1391,7 +1388,7 @@ ListboxGetItemAttributes( entry = Tcl_CreateHashEntry(listPtr->itemAttrTable, (char *) INT2PTR(index), &isNew); if (isNew) { - attrs = (ItemAttr *) ckalloc(sizeof(ItemAttr)); + attrs = ckalloc(sizeof(ItemAttr)); attrs->border = NULL; attrs->selBorder = NULL; attrs->fgColor = NULL; @@ -1451,7 +1448,7 @@ DestroyListbox( */ Tcl_DeleteHashTable(listPtr->selection); - ckfree((char *) listPtr->selection); + ckfree(listPtr->selection); /* * Free the item attribute hash table. @@ -1462,7 +1459,7 @@ DestroyListbox( ckfree(Tcl_GetHashValue(entry)); } Tcl_DeleteHashTable(listPtr->itemAttrTable); - ckfree((char *) listPtr->itemAttrTable); + ckfree(listPtr->itemAttrTable); /* * Free up all the stuff that requires special handling, then let @@ -1483,7 +1480,7 @@ DestroyListbox( listPtr->tkwin); Tcl_Release(listPtr->tkwin); listPtr->tkwin = NULL; - ckfree((char *) listPtr); + ckfree(listPtr); } /* @@ -1509,7 +1506,7 @@ DestroyListboxOptionTables( ClientData clientData, /* Pointer to the OptionTables struct */ Tcl_Interp *interp) /* Pointer to the calling interp */ { - ckfree((char *) clientData); + ckfree(clientData); return; } @@ -2452,7 +2449,7 @@ ListboxDeleteSubCmd( entry = Tcl_FindHashEntry(listPtr->itemAttrTable, (char *) INT2PTR(i)); if (entry != NULL) { - ckfree((char *)Tcl_GetHashValue(entry)); + ckfree(Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); } @@ -3447,7 +3444,7 @@ ListboxListVarProc( entry = Tcl_FindHashEntry(listPtr->itemAttrTable, (char *) INT2PTR(i)); if (entry != NULL) { - ckfree((char *) Tcl_GetHashValue(entry)); + ckfree(Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); } } diff --git a/generic/tkMenu.c b/generic/tkMenu.c index f9ea395..3bd3a4e 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -409,8 +409,7 @@ TkCreateMenuCmd( Tcl_Interp *interp) /* Interpreter we are creating the command * in. */ { - TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *) - ckalloc(sizeof(TkMenuOptionTables)); + TkMenuOptionTables *optionTablesPtr = ckalloc(sizeof(TkMenuOptionTables)); optionTablesPtr->menuOptionTable = Tk_CreateOptionTable(interp, tkMenuConfigSpecs); @@ -502,7 +501,7 @@ MenuCmd( * Tcl_EventuallyFree is called. */ - menuPtr = (TkMenu *) ckalloc(sizeof(TkMenu)); + menuPtr = ckalloc(sizeof(TkMenu)); memset(menuPtr, 0, sizeof(TkMenu)); menuPtr->tkwin = newWin; menuPtr->display = Tk_Display(newWin); @@ -1231,7 +1230,7 @@ DestroyMenuInstance( menuPtr->numEntries = i; } if (menuPtr->entries != NULL) { - ckfree((char *) menuPtr->entries); + ckfree(menuPtr->entries); } TkMenuFreeDrawOptions(menuPtr); Tk_FreeConfigOptions((char *) menuPtr, @@ -1501,7 +1500,7 @@ DestroyMenuEntry( TkpDestroyMenuEntry(mePtr); TkMenuEntryFreeDrawOptions(mePtr); Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, menuPtr->tkwin); - ckfree((char *) mePtr); + ckfree(mePtr); } /* @@ -1571,8 +1570,7 @@ ConfigureMenu( for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { - menuListPtr->errorStructPtr = (Tk_SavedOptions *) - ckalloc(sizeof(Tk_SavedOptions)); + menuListPtr->errorStructPtr = ckalloc(sizeof(Tk_SavedOptions)); result = Tk_SetOptions(interp, (char *) menuListPtr, menuListPtr->optionTablesPtr->menuOptionTable, objc, objv, menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL); @@ -1581,12 +1579,12 @@ ConfigureMenu( cleanupPtr != menuListPtr; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); - ckfree((char *) cleanupPtr->errorStructPtr); + ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } if (menuListPtr->errorStructPtr != NULL) { Tk_RestoreSavedOptions(menuListPtr->errorStructPtr); - ckfree((char *) menuListPtr->errorStructPtr); + ckfree(menuListPtr->errorStructPtr); menuListPtr->errorStructPtr = NULL; } return TCL_ERROR; @@ -1650,12 +1648,12 @@ ConfigureMenu( cleanupPtr != menuListPtr; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); - ckfree((char *) cleanupPtr->errorStructPtr); + ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } if (menuListPtr->errorStructPtr != NULL) { Tk_RestoreSavedOptions(menuListPtr->errorStructPtr); - ckfree((char *) menuListPtr->errorStructPtr); + ckfree(menuListPtr->errorStructPtr); menuListPtr->errorStructPtr = NULL; } return TCL_ERROR; @@ -1673,7 +1671,7 @@ ConfigureMenu( } menuListPtr->numEntries--; if (menuListPtr->numEntries == 0) { - ckfree((char *) menuListPtr->entries); + ckfree(menuListPtr->entries); menuListPtr->entries = NULL; } } @@ -1700,7 +1698,7 @@ ConfigureMenu( for (cleanupPtr = menuPtr->masterMenuPtr; cleanupPtr != NULL; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_FreeSavedOptions(cleanupPtr->errorStructPtr); - ckfree((char *) cleanupPtr->errorStructPtr); + ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } @@ -2293,8 +2291,7 @@ MenuNewEntry( * Create a new array of entries with an empty slot for the new entry. */ - newEntries = (TkMenuEntry **) - ckalloc((unsigned) (menuPtr->numEntries+1)*sizeof(TkMenuEntry *)); + newEntries = ckalloc((menuPtr->numEntries+1) * sizeof(TkMenuEntry *)); for (i = 0; i < index; i++) { newEntries[i] = menuPtr->entries[i]; } @@ -2303,11 +2300,11 @@ MenuNewEntry( newEntries[i+1]->index = i + 1; } if (menuPtr->numEntries != 0) { - ckfree((char *) menuPtr->entries); + ckfree(menuPtr->entries); } menuPtr->entries = newEntries; menuPtr->numEntries++; - mePtr = (TkMenuEntry *) ckalloc(sizeof(TkMenuEntry)); + mePtr = ckalloc(sizeof(TkMenuEntry)); menuPtr->entries[index] = mePtr; mePtr->type = type; mePtr->optionTable = menuPtr->optionTablesPtr->entryOptionTables[type]; @@ -2342,14 +2339,14 @@ MenuNewEntry( mePtr->nextCascadePtr = NULL; if (Tk_InitOptions(menuPtr->interp, (char *) mePtr, mePtr->optionTable, menuPtr->tkwin) != TCL_OK) { - ckfree((char *) mePtr); + ckfree(mePtr); return NULL; } TkMenuInitializeEntryDrawingFields(mePtr); if (TkpMenuNewEntry(mePtr) != TCL_OK) { Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, menuPtr->tkwin); - ckfree((char *) mePtr); + ckfree(mePtr); return NULL; } @@ -2439,7 +2436,7 @@ MenuAddOrInsert( } errorMenuPtr->numEntries--; if (errorMenuPtr->numEntries == 0) { - ckfree((char *) errorMenuPtr->entries); + ckfree(errorMenuPtr->entries); errorMenuPtr->entries = NULL; } if (errorMenuPtr == menuListPtr) { @@ -3230,7 +3227,7 @@ TkSetWindowMenuBar( } else { prevTopLevelPtr->nextPtr = topLevelListPtr->nextPtr; } - ckfree((char *) topLevelListPtr); + ckfree(topLevelListPtr); TkFreeMenuReferences(menuRefPtr); } } @@ -3295,8 +3292,7 @@ TkSetWindowMenuBar( * menu. */ - topLevelListPtr = (TkMenuTopLevelList *) - ckalloc(sizeof(TkMenuTopLevelList)); + topLevelListPtr = ckalloc(sizeof(TkMenuTopLevelList)); topLevelListPtr->tkwin = tkwin; topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr; menuRefPtr->topLevelListPtr = topLevelListPtr; @@ -3354,12 +3350,11 @@ Tcl_HashTable * TkGetMenuHashTable( Tcl_Interp *interp) /* The interp we need the hash table in.*/ { - Tcl_HashTable *menuTablePtr; - - menuTablePtr = (Tcl_HashTable *) + Tcl_HashTable *menuTablePtr = Tcl_GetAssocData(interp, MENU_HASH_KEY, NULL); + if (menuTablePtr == NULL) { - menuTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); + menuTablePtr = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(menuTablePtr, TCL_STRING_KEYS); Tcl_SetAssocData(interp, MENU_HASH_KEY, DestroyMenuHashTable, menuTablePtr); @@ -3400,7 +3395,7 @@ TkCreateMenuReferences( hashEntryPtr = Tcl_CreateHashEntry(menuTablePtr, pathName, &newEntry); if (newEntry) { - menuRefPtr = (TkMenuReferences *) ckalloc(sizeof(TkMenuReferences)); + menuRefPtr = ckalloc(sizeof(TkMenuReferences)); menuRefPtr->menuPtr = NULL; menuRefPtr->topLevelListPtr = NULL; menuRefPtr->parentEntryPtr = NULL; @@ -3505,7 +3500,7 @@ TkFreeMenuReferences( && (menuRefPtr->parentEntryPtr == NULL) && (menuRefPtr->topLevelListPtr == NULL)) { Tcl_DeleteHashEntry(menuRefPtr->hashEntryPtr); - ckfree((char *) menuRefPtr); + ckfree(menuRefPtr); return 1; } return 0; @@ -3551,7 +3546,7 @@ DeleteMenuCloneEntries( } menuListPtr->numEntries -= numDeleted; if (menuListPtr->numEntries == 0) { - ckfree((char *) menuListPtr->entries); + ckfree(menuListPtr->entries); menuListPtr->entries = NULL; } if ((menuListPtr->active >= first) diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 17fc6c6..d8af461 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -635,7 +635,7 @@ ConfigureMenuButton( if (mbPtr->text != NULL) { ckfree(mbPtr->text); } - mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1)); + mbPtr->text = ckalloc(strlen(value) + 1); strcpy(mbPtr->text, value); } Tcl_TraceVar(interp, mbPtr->textVarName, @@ -907,7 +907,7 @@ MenuButtonTextVarProc( ckfree(mbPtr->text); } len = 1 + (unsigned) strlen(value); - mbPtr->text = (char *) ckalloc(len); + mbPtr->text = ckalloc(len); memcpy(mbPtr->text, value, len); TkpComputeMenuButtonGeometry(mbPtr); diff --git a/generic/tkMessage.c b/generic/tkMessage.c index ce1bbb3..19df9f3 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -243,7 +243,7 @@ Tk_MessageObjCmd( optionTable = Tk_CreateOptionTable(interp, optionSpecs); - msgPtr = (Message *) ckalloc(sizeof(Message)); + msgPtr = ckalloc(sizeof(Message)); memset(msgPtr, 0, (size_t) sizeof(Message)); /* @@ -413,7 +413,7 @@ DestroyMessage( } Tk_FreeConfigOptions((char *) msgPtr, msgPtr->optionTable, msgPtr->tkwin); msgPtr->tkwin = NULL; - ckfree((char *) msgPtr); + ckfree(msgPtr); } /* @@ -864,7 +864,7 @@ MessageTextVarProc( ckfree(msgPtr->string); } msgPtr->numChars = Tcl_NumUtfChars(value, -1); - msgPtr->string = (char *) ckalloc((unsigned) (strlen(value) + 1)); + msgPtr->string = ckalloc(strlen(value) + 1); strcpy(msgPtr->string, value); ComputeMessageGeometry(msgPtr); diff --git a/generic/tkObj.c b/generic/tkObj.c index d51b28f..dad50e2 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -312,7 +312,7 @@ FreePixelInternalRep( if (!SIMPLE_PIXELREP(objPtr)) { pixelPtr = GET_COMPLEXPIXEL(objPtr); - ckfree((char *) pixelPtr); + ckfree(pixelPtr); } SET_SIMPLEPIXEL(objPtr, 0); objPtr->typePtr = NULL; @@ -349,7 +349,7 @@ DupPixelInternalRep( SET_SIMPLEPIXEL(copyPtr, GET_SIMPLEPIXEL(srcPtr)); } else { oldPtr = GET_COMPLEXPIXEL(srcPtr); - newPtr = (PixelRep *) ckalloc(sizeof(PixelRep)); + newPtr = ckalloc(sizeof(PixelRep)); newPtr->value = oldPtr->value; newPtr->units = oldPtr->units; newPtr->tkwin = oldPtr->tkwin; @@ -433,7 +433,7 @@ SetPixelFromAny( if ((units < 0) && (i == d)) { SET_SIMPLEPIXEL(objPtr, i); } else { - PixelRep *pixelPtr = (PixelRep *) ckalloc(sizeof(PixelRep)); + PixelRep *pixelPtr = ckalloc(sizeof(PixelRep)); pixelPtr->value = d; pixelPtr->units = units; @@ -564,7 +564,7 @@ DupMMInternalRep( copyPtr->typePtr = srcPtr->typePtr; oldPtr = srcPtr->internalRep.otherValuePtr; - newPtr = (MMRep *) ckalloc(sizeof(MMRep)); + newPtr = ckalloc(sizeof(MMRep)); newPtr->value = oldPtr->value; newPtr->units = oldPtr->units; newPtr->tkwin = oldPtr->tkwin; @@ -608,7 +608,7 @@ UpdateStringOfMM( Tcl_PrintDouble(NULL, mmPtr->value, buffer); len = (int)strlen(buffer); - objPtr->bytes = (char *) ckalloc((unsigned) len + 1); + objPtr->bytes = ckalloc(len + 1); strcpy(objPtr->bytes, buffer); objPtr->length = len; } @@ -727,7 +727,7 @@ SetMMFromAny( objPtr->typePtr = &mmObjType; - mmPtr = (MMRep *) ckalloc(sizeof(MMRep)); + mmPtr = ckalloc(sizeof(MMRep)); mmPtr->value = d; mmPtr->units = units; mmPtr->tkwin = NULL; @@ -837,7 +837,7 @@ SetWindowFromAny( typePtr->freeIntRepProc(objPtr); } - winPtr = (WindowRep *) ckalloc(sizeof(WindowRep)); + winPtr = ckalloc(sizeof(WindowRep)); winPtr->tkwin = NULL; winPtr->mainPtr = NULL; winPtr->epoch = 0; @@ -874,7 +874,7 @@ DupWindowInternalRep( register WindowRep *oldPtr, *newPtr; oldPtr = srcPtr->internalRep.otherValuePtr; - newPtr = (WindowRep *) ckalloc(sizeof(WindowRep)); + newPtr = ckalloc(sizeof(WindowRep)); newPtr->tkwin = oldPtr->tkwin; newPtr->mainPtr = oldPtr->mainPtr; newPtr->epoch = oldPtr->epoch; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 9f0655e..e054040 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -374,7 +374,7 @@ DoConfig( if (nullValue) { newStr = NULL; } else { - newStr = (char *) ckalloc((unsigned) (strlen(value) + 1)); + newStr = ckalloc(strlen(value) + 1); strcpy(newStr, value); } oldStr = *((char **) ptr); @@ -720,7 +720,7 @@ FormatConfigInfo( result = Tcl_Merge(5, argv); if (freeProc != NULL) { if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { - ckfree((char *) argv[4]); + ckfree(argv[4]); } else { freeProc((char *) argv[4]); } @@ -941,7 +941,7 @@ Tk_ConfigureValue( Tcl_SetResult(interp, (char *) result, TCL_VOLATILE); if (freeProc != NULL) { if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { - ckfree((char *) result); + ckfree(result); } else { freeProc((char *) result); } @@ -1073,7 +1073,7 @@ GetCachedSpecs( specCacheTablePtr = Tcl_GetAssocData(interp, "tkConfigSpec.threadTable", NULL); if (specCacheTablePtr == NULL) { - specCacheTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); + specCacheTablePtr = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(specCacheTablePtr, TCL_ONE_WORD_KEYS); Tcl_SetAssocData(interp, "tkConfigSpec.threadTable", DeleteSpecCacheTable, specCacheTablePtr); @@ -1106,7 +1106,7 @@ GetCachedSpecs( * from the master copy. */ - cachedSpecs = (Tk_ConfigSpec *) ckalloc(entrySpace); + cachedSpecs = ckalloc(entrySpace); memcpy(cachedSpecs, staticSpecs, entrySpace); Tcl_SetHashValue(entryPtr, cachedSpecs); @@ -1172,7 +1172,7 @@ DeleteSpecCacheTable( ckfree(Tcl_GetHashValue(entryPtr)); } Tcl_DeleteHashTable(tablePtr); - ckfree((char *) tablePtr); + ckfree(tablePtr); } /* diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c index 05041b7..d87c68e 100644 --- a/generic/tkOldTest.c +++ b/generic/tkOldTest.c @@ -168,14 +168,14 @@ ImageCreate( varName = argv[i+1]; } - timPtr = (TImageMaster *) ckalloc(sizeof(TImageMaster)); + timPtr = ckalloc(sizeof(TImageMaster)); timPtr->master = master; timPtr->interp = interp; timPtr->width = 30; timPtr->height = 15; - timPtr->imageName = (char *) ckalloc((unsigned) (strlen(name) + 1)); + timPtr->imageName = ckalloc((unsigned) (strlen(name) + 1)); strcpy(timPtr->imageName, name); - timPtr->varName = (char *) ckalloc((unsigned) (strlen(varName) + 1)); + timPtr->varName = ckalloc((unsigned) (strlen(varName) + 1)); strcpy(timPtr->varName, varName); Tcl_CreateCommand(interp, name, ImageCmd, timPtr, NULL); *clientDataPtr = timPtr; @@ -273,7 +273,7 @@ ImageGet( Tcl_SetVar(timPtr->interp, timPtr->varName, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - instPtr = (TImageInstance *) ckalloc(sizeof(TImageInstance)); + instPtr = ckalloc(sizeof(TImageInstance)); instPtr->masterPtr = timPtr; instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; @@ -364,7 +364,7 @@ ImageFree( TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); - ckfree((char *) instPtr); + ckfree(instPtr); } /* @@ -400,7 +400,7 @@ ImageDelete( Tcl_DeleteCommand(timPtr->interp, timPtr->imageName); ckfree(timPtr->imageName); ckfree(timPtr->varName); - ckfree((char *) timPtr); + ckfree(timPtr); } /* diff --git a/generic/tkOption.c b/generic/tkOption.c index d3242fd..0463fd5 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -537,7 +537,7 @@ Tk_GetOption( */ classNameLength = (unsigned) (masqName - name); - masqClass = (char *) ckalloc(classNameLength + 1); + masqClass = ckalloc(classNameLength + 1); strncpy(masqClass, name, classNameLength); masqClass[classNameLength] = '\0'; @@ -1116,9 +1116,9 @@ ReadOptionFile( fileName, "\":", Tcl_PosixError(interp), NULL); Tcl_Close(NULL, chan); return TCL_ERROR; - } - buffer = ckalloc((unsigned) bufferSize+1); + + buffer = ckalloc(bufferSize + 1); bufferSize = Tcl_Read(chan, buffer, bufferSize); if (bufferSize < 0) { Tcl_AppendResult(interp, "error reading file \"", fileName, "\":", @@ -1154,7 +1154,7 @@ static ElArray * NewArray( int numEls) /* How many elements of space to allocate. */ { - register ElArray *arrayPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(numEls)); + register ElArray *arrayPtr = ckalloc(EL_ARRAY_SIZE(numEls)); arrayPtr->arraySize = numEls; arrayPtr->numUsed = 0; @@ -1191,8 +1191,7 @@ ExtendArray( if (arrayPtr->numUsed >= arrayPtr->arraySize) { register int newSize = 2*arrayPtr->arraySize; - arrayPtr = (ElArray *) - ckrealloc((char *) arrayPtr, EL_ARRAY_SIZE(newSize)); + arrayPtr = ckrealloc(arrayPtr, EL_ARRAY_SIZE(newSize)); arrayPtr->arraySize = newSize; arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed]; } @@ -1310,11 +1309,11 @@ SetupStacks( */ if (tsdPtr->curLevel >= tsdPtr->numLevels) { - StackLevel *newLevels = (StackLevel *) - ckalloc((unsigned) (tsdPtr->numLevels*2*sizeof(StackLevel))); + StackLevel *newLevels = + ckalloc(tsdPtr->numLevels * 2 * sizeof(StackLevel)); memcpy(newLevels, tsdPtr->levels, tsdPtr->numLevels * sizeof(StackLevel)); - ckfree((char *) tsdPtr->levels); + ckfree(tsdPtr->levels); tsdPtr->numLevels *= 2; tsdPtr->levels = newLevels; } @@ -1433,9 +1432,9 @@ OptionThreadExitProc( int i; for (i = 0; i < NUM_STACKS; i++) { - ckfree((char *) tsdPtr->stacks[i]); + ckfree(tsdPtr->stacks[i]); } - ckfree((char *) tsdPtr->levels); + ckfree(tsdPtr->levels); tsdPtr->initialized = 0; } } @@ -1479,8 +1478,7 @@ OptionInit( tsdPtr->curLevel = -1; tsdPtr->serial = 0; - tsdPtr->levels = (StackLevel *) - ckalloc((unsigned) (5*sizeof(StackLevel))); + tsdPtr->levels = ckalloc(5 * sizeof(StackLevel)); for (i = 0; i < NUM_STACKS; i++) { tsdPtr->stacks[i] = NewArray(10); tsdPtr->levels[0].bases[i] = 0; @@ -1536,7 +1534,7 @@ ClearOptionTree( ClearOptionTree(elPtr->child.arrayPtr); } } - ckfree((char *) arrayPtr); + ckfree(arrayPtr); } /* diff --git a/generic/tkPack.c b/generic/tkPack.c index d57d2bf..07047a9 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -1035,7 +1035,7 @@ GetPacker( if (!isNew) { return Tcl_GetHashValue(hPtr); } - packPtr = (Packer *) ckalloc(sizeof(Packer)); + packPtr = ckalloc(sizeof(Packer)); packPtr->tkwin = tkwin; packPtr->masterPtr = NULL; packPtr->nextPtr = NULL; @@ -1368,7 +1368,8 @@ DestroyPacker( * dead. */ { register Packer *packPtr = (Packer *) memPtr; - ckfree((char *) packPtr); + + ckfree(packPtr); } /* diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 3df5024..7b05815 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -401,7 +401,7 @@ Tk_PanedWindowObjCmd( * easy access to it in the future. */ - pwOpts = (OptionTables *) ckalloc(sizeof(OptionTables)); + pwOpts = ckalloc(sizeof(OptionTables)); /* * Set up an exit handler to free the optionTables struct. @@ -424,7 +424,7 @@ Tk_PanedWindowObjCmd( * Allocate and initialize the widget record. */ - pwPtr = (PanedWindow *) ckalloc(sizeof(PanedWindow)); + pwPtr = ckalloc(sizeof(PanedWindow)); memset((void *)pwPtr, 0, (sizeof(PanedWindow))); pwPtr->tkwin = tkwin; pwPtr->display = Tk_Display(tkwin); @@ -878,7 +878,7 @@ ConfigureSlaves( * structures may already have existed, some may be new. */ - inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); + inserts = ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); insertIndex = 0; /* @@ -945,7 +945,7 @@ ConfigureSlaves( * out with their "natural" dimensions. */ - slavePtr = (Slave *) ckalloc(sizeof(Slave)); + slavePtr = ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, pwPtr->tkwin); @@ -984,8 +984,8 @@ ConfigureSlaves( * Allocate the new slaves array, then copy the slaves into it, in order. */ - i = sizeof(Slave *) * (pwPtr->numSlaves+numNewSlaves); - newSlaves = (Slave **)ckalloc((unsigned) i); + i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves); + newSlaves = ckalloc(i); memset(newSlaves, 0, (size_t) i); if (index == -1) { /* @@ -1028,8 +1028,8 @@ ConfigureSlaves( * Make the new slaves array the paned window's slave array, and clean up. */ - ckfree((void *)pwPtr->slaves); - ckfree((void *)inserts); + ckfree(pwPtr->slaves); + ckfree(inserts); pwPtr->slaves = newSlaves; /* @@ -1539,11 +1539,11 @@ DestroyPanedWindow( Tk_ManageGeometry(pwPtr->slaves[i]->tkwin, NULL, NULL); Tk_FreeConfigOptions((char *) pwPtr->slaves[i], pwPtr->slaveOpts, pwPtr->tkwin); - ckfree((char *) pwPtr->slaves[i]); + ckfree(pwPtr->slaves[i]); pwPtr->slaves[i] = NULL; } if (pwPtr->slaves) { - ckfree((char *) pwPtr->slaves); + ckfree(pwPtr->slaves); } /* @@ -1644,7 +1644,7 @@ PanedWindowLostSlaveProc( SlaveStructureProc, slavePtr); Tk_UnmapWindow(slavePtr->tkwin); slavePtr->tkwin = NULL; - ckfree((char *) slavePtr); + ckfree(slavePtr); ComputeGeometry(pwPtr); } @@ -2080,7 +2080,7 @@ SlaveStructureProc( if (eventPtr->type == DestroyNotify) { Unlink(slavePtr); slavePtr->tkwin = NULL; - ckfree((char *) slavePtr); + ckfree(slavePtr); ComputeGeometry(pwPtr); } } @@ -2286,8 +2286,7 @@ DestroyOptionTables( ClientData clientData, /* Pointer to the OptionTables struct */ Tcl_Interp *interp) /* Pointer to the calling interp */ { - ckfree((char *) clientData); - return; + ckfree(clientData); } /* diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 62ea86d..bce5083 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -394,7 +394,7 @@ CreateSlave( * populate it with some default values. */ - slavePtr = (Slave *) ckalloc(sizeof(Slave)); + slavePtr = ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); slavePtr->tkwin = tkwin; slavePtr->inTkwin = None; @@ -429,7 +429,7 @@ FreeSlave( { Tk_FreeConfigOptions((char *) slavePtr, slavePtr->optionTable, slavePtr->tkwin); - ckfree((char *) slavePtr); + ckfree(slavePtr); } /* @@ -540,7 +540,7 @@ CreateMaster( hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew); if (isNew) { - masterPtr = (Master *) ckalloc(sizeof(Master)); + masterPtr = ckalloc(sizeof(Master)); masterPtr->tkwin = tkwin; masterPtr->slavePtr = NULL; masterPtr->abortPtr = NULL; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 34fd29b..0834f99 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -141,7 +141,7 @@ Tk_CreateSelHandler( for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { - selPtr = (TkSelHandler *) ckalloc(sizeof(TkSelHandler)); + selPtr = ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; break; @@ -154,7 +154,7 @@ Tk_CreateSelHandler( */ if (selPtr->proc == HandleTclCommand) { - ckfree((char *) selPtr->clientData); + ckfree(selPtr->clientData); } break; } @@ -179,7 +179,7 @@ Tk_CreateSelHandler( target = winPtr->dispPtr->utf8Atom; for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { - selPtr = (TkSelHandler *) ckalloc(sizeof(TkSelHandler)); + selPtr = ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; selPtr->selection = selection; @@ -322,7 +322,7 @@ Tk_DeleteSelHandler( ((CommandInfo *) selPtr->clientData)->interp = NULL; Tcl_EventuallyFree(selPtr->clientData, TCL_DYNAMIC); } - ckfree((char *) selPtr); + ckfree(selPtr); } /* @@ -384,7 +384,7 @@ Tk_OwnSelection( } } if (infoPtr == NULL) { - infoPtr = (TkSelectionInfo *) ckalloc(sizeof(TkSelectionInfo)); + infoPtr = ckalloc(sizeof(TkSelectionInfo)); infoPtr->selection = selection; infoPtr->nextPtr = dispPtr->selectionInfoPtr; dispPtr->selectionInfoPtr = infoPtr; @@ -399,7 +399,7 @@ Tk_OwnSelection( * memory leak. */ - ckfree((char *) infoPtr->clearData); + ckfree(infoPtr->clearData); } } @@ -492,7 +492,7 @@ Tk_ClearSelection( if (infoPtr != NULL) { clearProc = infoPtr->clearProc; clearData = infoPtr->clearData; - ckfree((char *) infoPtr); + ckfree(infoPtr); } XSetSelectionOwner(winPtr->display, selection, None, CurrentTime); @@ -901,8 +901,8 @@ Tk_SelectionObjCmd( if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { - cmdInfoPtr = (CommandInfo *) ckalloc((unsigned) ( - (Tk_Offset(CommandInfo, command) + 1) + cmdLength)); + cmdInfoPtr = ckalloc(Tk_Offset(CommandInfo, command) + + 1 + cmdLength); cmdInfoPtr->interp = interp; cmdInfoPtr->charOffset = 0; cmdInfoPtr->byteOffset = 0; @@ -1004,7 +1004,7 @@ Tk_SelectionObjCmd( Tk_OwnSelection(tkwin, selection, NULL, NULL); return TCL_OK; } - lostPtr = (LostCommand *) ckalloc(sizeof(LostCommand)); + lostPtr = ckalloc(sizeof(LostCommand)); lostPtr->interp = interp; lostPtr->cmdObj = commandObj; Tcl_IncrRefCount(commandObj); @@ -1119,7 +1119,7 @@ TkSelDeadWindow( ((CommandInfo *) selPtr->clientData)->interp = NULL; Tcl_EventuallyFree(selPtr->clientData, TCL_DYNAMIC); } - ckfree((char *) selPtr); + ckfree(selPtr); } /* @@ -1131,9 +1131,9 @@ TkSelDeadWindow( nextPtr = infoPtr->nextPtr; if (infoPtr->owner == (Tk_Window) winPtr) { if (infoPtr->clearProc == LostSelection) { - ckfree((char *) infoPtr->clearData); + ckfree(infoPtr->clearData); } - ckfree((char *) infoPtr); + ckfree(infoPtr); infoPtr = prevPtr; if (prevPtr == NULL) { winPtr->dispPtr->selectionInfoPtr = nextPtr; @@ -1258,7 +1258,7 @@ TkSelClearSelection( if (infoPtr->clearProc != NULL) { infoPtr->clearProc(infoPtr->clearData); } - ckfree((char *) infoPtr); + ckfree(infoPtr); } } @@ -1369,7 +1369,7 @@ HandleTclCommand( if (spaceNeeded < MAX_STATIC_SIZE) { command = staticSpace; } else { - command = (char *) ckalloc((unsigned) spaceNeeded); + command = ckalloc(spaceNeeded); } sprintf(command, "%s %d %d", cmdInfoPtr->command, charOffset, maxBytes); @@ -1597,7 +1597,7 @@ LostSelection( */ Tcl_DecrRefCount(lostPtr->cmdObj); - ckfree((char *) lostPtr); + ckfree(lostPtr); } /* diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 5954474..9bf7ff6 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -162,8 +162,8 @@ SquareObjCmd( * just the non-NULL/0 items. */ - squarePtr = (Square *) ckalloc(sizeof(Square)); - memset((void *) squarePtr, 0, (sizeof(Square))); + squarePtr = ckalloc(sizeof(Square)); + memset(squarePtr, 0, sizeof(Square)); squarePtr->tkwin = tkwin; squarePtr->display = Tk_Display(tkwin); @@ -177,7 +177,7 @@ SquareObjCmd( if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(squarePtr->tkwin); - ckfree((char *) squarePtr); + ckfree(squarePtr); return TCL_ERROR; } @@ -560,7 +560,7 @@ SquareDestroy( { Square *squarePtr = (Square *) memPtr; - ckfree((char *) squarePtr); + ckfree(squarePtr); } /* diff --git a/generic/tkStyle.c b/generic/tkStyle.c index fda6f7b..bf683bc 100644 --- a/generic/tkStyle.c +++ b/generic/tkStyle.c @@ -255,7 +255,7 @@ TkStylePkgFree( entryPtr = Tcl_FirstHashEntry(&tsdPtr->styleTable, &search); while (entryPtr != NULL) { - ckfree((char *) Tcl_GetHashValue(entryPtr)); + ckfree(Tcl_GetHashValue(entryPtr)); entryPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&tsdPtr->styleTable); @@ -268,7 +268,7 @@ TkStylePkgFree( while (entryPtr != NULL) { enginePtr = Tcl_GetHashValue(entryPtr); FreeStyleEngine(enginePtr); - ckfree((char *) enginePtr); + ckfree(enginePtr); entryPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&tsdPtr->engineTable); @@ -281,7 +281,7 @@ TkStylePkgFree( FreeElement(tsdPtr->elements+i); } Tcl_DeleteHashTable(&tsdPtr->elementTable); - ckfree((char *) tsdPtr->elements); + ckfree(tsdPtr->elements); } /* @@ -333,7 +333,7 @@ Tk_RegisterStyleEngine( * Allocate and intitialize a new engine. */ - enginePtr = (StyleEngine *) ckalloc(sizeof(StyleEngine)); + enginePtr = ckalloc(sizeof(StyleEngine)); InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr), (StyleEngine *) parent); Tcl_SetHashValue(entryPtr, enginePtr); @@ -391,7 +391,7 @@ InitStyleEngine( */ if (tsdPtr->nbElements > 0) { - enginePtr->elements = (StyledElement *) ckalloc( + enginePtr->elements = ckalloc( sizeof(StyledElement) * tsdPtr->nbElements); for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) { InitStyledElement(enginePtr->elements+elementId); @@ -432,7 +432,7 @@ FreeStyleEngine( for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) { FreeStyledElement(enginePtr->elements+elementId); } - ckfree((char *) enginePtr->elements); + ckfree(enginePtr->elements); } /* @@ -580,7 +580,7 @@ FreeStyledElement( for (i = 0; i < elementPtr->nbWidgetSpecs; i++) { FreeWidgetSpec(elementPtr->widgetSpecs+i); } - ckfree((char *) elementPtr->widgetSpecs); + ckfree(elementPtr->widgetSpecs); } /* @@ -644,7 +644,7 @@ CreateElement( * Reallocate element table. */ - tsdPtr->elements = (Element *) ckrealloc((char *) tsdPtr->elements, + tsdPtr->elements = ckrealloc(tsdPtr->elements, sizeof(Element) * tsdPtr->nbElements); InitElement(tsdPtr->elements+elementId, Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId, @@ -658,8 +658,7 @@ CreateElement( while (engineEntryPtr != NULL) { enginePtr = Tcl_GetHashValue(engineEntryPtr); - enginePtr->elements = (StyledElement *) ckrealloc( - (char *) enginePtr->elements, + enginePtr->elements = ckrealloc(enginePtr->elements, sizeof(StyledElement) * tsdPtr->nbElements); InitStyledElement(enginePtr->elements+elementId); @@ -789,7 +788,7 @@ Tk_RegisterStyledElement( elementPtr = ((StyleEngine *) engine)->elements+elementId; - specPtr = (Tk_ElementSpec *) ckalloc(sizeof(Tk_ElementSpec)); + specPtr = ckalloc(sizeof(Tk_ElementSpec)); specPtr->version = templatePtr->version; specPtr->name = ckalloc(strlen(templatePtr->name)+1); strcpy(specPtr->name, templatePtr->name); @@ -798,7 +797,7 @@ Tk_RegisterStyledElement( srcOptions->name != NULL; nbOptions++, srcOptions++) { /* empty body */ } - specPtr->options = (Tk_ElementOptionSpec *) + specPtr->options = ckalloc(sizeof(Tk_ElementOptionSpec) * (nbOptions+1)); for (srcOptions = templatePtr->options, dstOptions = specPtr->options; /* End condition within loop */; srcOptions++, dstOptions++) { @@ -926,7 +925,7 @@ InitWidgetSpec( * Build the widget option list. */ - widgetSpecPtr->optionsPtr = (const Tk_OptionSpec **) + widgetSpecPtr->optionsPtr = ckalloc(sizeof(Tk_OptionSpec *) * nbOptions); for (i = 0, elementOptionPtr = elementPtr->specPtr->options; i < nbOptions; i++, elementOptionPtr++) { @@ -967,7 +966,7 @@ FreeWidgetSpec( StyledWidgetSpec *widgetSpecPtr) /* The widget spec to free. */ { - ckfree((char *) widgetSpecPtr->optionsPtr); + ckfree(widgetSpecPtr->optionsPtr); } /* @@ -1011,8 +1010,7 @@ GetWidgetSpec( */ i = elementPtr->nbWidgetSpecs++; - elementPtr->widgetSpecs = (StyledWidgetSpec *) ckrealloc( - (char *) elementPtr->widgetSpecs, + elementPtr->widgetSpecs = ckrealloc(elementPtr->widgetSpecs, sizeof(StyledWidgetSpec) * elementPtr->nbWidgetSpecs); widgetSpecPtr = elementPtr->widgetSpecs+i; InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable); @@ -1257,7 +1255,7 @@ Tk_CreateStyle( * Allocate and intitialize a new style. */ - stylePtr = (Style *) ckalloc(sizeof(Style)); + stylePtr = ckalloc(sizeof(Style)); InitStyle(stylePtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr), (engine!=NULL ? (StyleEngine*) engine : tsdPtr->defaultEnginePtr), clientData); diff --git a/generic/tkTest.c b/generic/tkTest.c index 58093c2..6eee7e0 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -466,7 +466,7 @@ TestdeleteappsCmd( while (newAppPtr != NULL) { nextPtr = newAppPtr->nextPtr; Tcl_DeleteInterp(newAppPtr->interp); - ckfree((char *) newAppPtr); + ckfree(newAppPtr); newAppPtr = nextPtr; } @@ -640,7 +640,7 @@ TestobjconfigObjCmd( } Tk_SetClass(tkwin, "Test"); - recordPtr = (TypesRecord *) ckalloc(sizeof(TypesRecord)); + recordPtr = ckalloc(sizeof(TypesRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = optionTable; recordPtr->header.tkwin = tkwin; @@ -675,7 +675,7 @@ TestobjconfigObjCmd( } } else { Tk_DestroyWindow(tkwin); - ckfree((char *) recordPtr); + ckfree(recordPtr); } if (result == TCL_OK) { Tcl_SetObjResult(interp, objv[2]); @@ -697,8 +697,7 @@ TestobjconfigObjCmd( optionTable = Tk_CreateOptionTable(interp, baseSpecs); tables[index] = optionTable; - recordPtr = (ExtensionWidgetRecord *) - ckalloc(sizeof(ExtensionWidgetRecord)); + recordPtr = ckalloc(sizeof(ExtensionWidgetRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = optionTable; recordPtr->header.tkwin = tkwin; @@ -750,8 +749,7 @@ TestobjconfigObjCmd( optionTable = Tk_CreateOptionTable(interp, extensionSpecs); tables[index] = optionTable; - recordPtr = (ExtensionWidgetRecord *) ckalloc( - sizeof(ExtensionWidgetRecord)); + recordPtr = ckalloc(sizeof(ExtensionWidgetRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = optionTable; recordPtr->header.tkwin = tkwin; @@ -916,7 +914,7 @@ TestobjconfigObjCmd( } Tk_SetClass(tkwin, "Test"); - recordPtr = (InternalRecord *) ckalloc(sizeof(InternalRecord)); + recordPtr = ckalloc(sizeof(InternalRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = optionTable; recordPtr->header.tkwin = tkwin; @@ -952,7 +950,7 @@ TestobjconfigObjCmd( } } else { Tk_DestroyWindow(tkwin); - ckfree((char *) recordPtr); + ckfree(recordPtr); } if (result == TCL_OK) { Tcl_SetObjResult(interp, objv[2]); @@ -989,7 +987,7 @@ TestobjconfigObjCmd( return TCL_ERROR; } - recordPtr = (FiveRecord *) ckalloc(sizeof(FiveRecord)); + recordPtr = ckalloc(sizeof(FiveRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = Tk_CreateOptionTable(interp, smallSpecs); @@ -1014,7 +1012,7 @@ TestobjconfigObjCmd( } } if (result != TCL_OK) { - ckfree((char *) recordPtr); + ckfree(recordPtr); } break; @@ -1068,7 +1066,7 @@ TestobjconfigObjCmd( } Tk_SetClass(tkwin, "Test"); - recordPtr = (SlaveRecord *) ckalloc(sizeof(SlaveRecord)); + recordPtr = ckalloc(sizeof(SlaveRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = Tk_CreateOptionTable(interp, slaveSpecs); @@ -1096,7 +1094,7 @@ TestobjconfigObjCmd( } if (result != TCL_OK) { Tk_DestroyWindow(tkwin); - ckfree((char *) recordPtr); + ckfree(recordPtr); } } } @@ -1398,14 +1396,14 @@ ImageCreate( varName = Tcl_GetString(objv[i+1]); } - timPtr = (TImageMaster *) ckalloc(sizeof(TImageMaster)); + timPtr = ckalloc(sizeof(TImageMaster)); timPtr->master = master; timPtr->interp = interp; timPtr->width = 30; timPtr->height = 15; - timPtr->imageName = (char *) ckalloc((unsigned) (strlen(name) + 1)); + timPtr->imageName = ckalloc(strlen(name) + 1); strcpy(timPtr->imageName, name); - timPtr->varName = (char *) ckalloc((unsigned) (strlen(varName) + 1)); + timPtr->varName = ckalloc(strlen(varName) + 1); strcpy(timPtr->varName, varName); Tcl_CreateCommand(interp, name, ImageCmd, timPtr, NULL); *clientDataPtr = timPtr; @@ -1503,7 +1501,7 @@ ImageGet( Tcl_SetVar(timPtr->interp, timPtr->varName, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - instPtr = (TImageInstance *) ckalloc(sizeof(TImageInstance)); + instPtr = ckalloc(sizeof(TImageInstance)); instPtr->masterPtr = timPtr; instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; @@ -1594,7 +1592,7 @@ ImageFree( TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); - ckfree((char *) instPtr); + ckfree(instPtr); } /* @@ -1630,7 +1628,7 @@ ImageDelete( Tcl_DeleteCommand(timPtr->interp, timPtr->imageName); ckfree(timPtr->imageName); ckfree(timPtr->varName); - ckfree((char *) timPtr); + ckfree(timPtr); } /* @@ -2025,7 +2023,7 @@ CustomOptionSet( if (internalPtr != NULL) { if ((*value) != NULL) { string = Tcl_GetStringFromObj((*value), &length); - newStr = ckalloc((size_t) (length + 1)); + newStr = ckalloc(length + 1); strcpy(newStr, string); } else { newStr = NULL; diff --git a/generic/tkText.c b/generic/tkText.c index 4c4ca20..da41628 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -521,7 +521,7 @@ CreateWidget( * and 'insert', 'current' mark pointers are all NULL to start. */ - textPtr = (TkText *) ckalloc(sizeof(TkText)); + textPtr = ckalloc(sizeof(TkText)); memset(textPtr, 0, sizeof(TkText)); textPtr->tkwin = newWin; @@ -532,7 +532,7 @@ CreateWidget( textPtr, TextCmdDeletedProc); if (sharedPtr == NULL) { - sharedPtr = (TkSharedText *) ckalloc(sizeof(TkSharedText)); + sharedPtr = ckalloc(sizeof(TkSharedText)); memset(sharedPtr, 0, sizeof(TkSharedText)); sharedPtr->refCount = 0; @@ -630,7 +630,7 @@ CreateWidget( */ textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL); - textPtr->selTagPtr->reliefString = (char *) + textPtr->selTagPtr->reliefString = ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF)); strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF); Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief); @@ -1115,8 +1115,7 @@ TextWidgetObjCmd( objc -= 2; objv += 2; - indices = (TkTextIndex *) - ckalloc((objc + 1) * sizeof(TkTextIndex)); + indices = ckalloc((objc + 1) * sizeof(TkTextIndex)); /* * First pass verifies that all indices are valid. @@ -1128,7 +1127,7 @@ TextWidgetObjCmd( if (indexPtr == NULL) { result = TCL_ERROR; - ckfree((char *) indices); + ckfree(indices); goto done; } indices[i] = *indexPtr; @@ -1144,7 +1143,7 @@ TextWidgetObjCmd( COUNT_INDICES); objc++; } - useIdx = (char *) ckalloc((unsigned) objc); + useIdx = ckalloc(objc); memset(useIdx, 0, (unsigned) objc); /* @@ -1208,7 +1207,7 @@ TextWidgetObjCmd( &indices[i+1], 1); } } - ckfree((char *) indices); + ckfree(indices); } } break; @@ -1516,7 +1515,7 @@ TextWidgetObjCmd( done: textPtr->refCount--; if (textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } return result; } @@ -1891,10 +1890,10 @@ DestroyText( TkTextDeleteTag(textPtr, textPtr->selTagPtr); TkBTreeUnlinkSegment(textPtr->insertMarkPtr, textPtr->insertMarkPtr->body.mark.linePtr); - ckfree((char *) textPtr->insertMarkPtr); + ckfree(textPtr->insertMarkPtr); TkBTreeUnlinkSegment(textPtr->currentMarkPtr, textPtr->currentMarkPtr->body.mark.linePtr); - ckfree((char *) textPtr->currentMarkPtr); + ckfree(textPtr->currentMarkPtr); /* * Now we've cleaned up everything of relevance to us in the B-tree, so we @@ -1960,7 +1959,7 @@ DestroyText( Tcl_DeleteHashTable(&sharedTextPtr->tagTable); for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->markTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - ckfree((char *) Tcl_GetHashValue(hPtr)); + ckfree(Tcl_GetHashValue(hPtr)); } Tcl_DeleteHashTable(&sharedTextPtr->markTable); TkUndoFreeStack(sharedTextPtr->undoStack); @@ -1971,11 +1970,11 @@ DestroyText( if (sharedTextPtr->bindingTable != NULL) { Tk_DeleteBindingTable(sharedTextPtr->bindingTable); } - ckfree((char *) sharedTextPtr); + ckfree(sharedTextPtr); } if (textPtr->tabArrayPtr != NULL) { - ckfree((char *) textPtr->tabArrayPtr); + ckfree(textPtr->tabArrayPtr); } if (textPtr->insertBlinkHandler != NULL) { Tcl_DeleteTimerHandler(textPtr->insertBlinkHandler); @@ -1985,7 +1984,7 @@ DestroyText( textPtr->refCount--; Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd); if (textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } } @@ -2142,7 +2141,7 @@ ConfigureText( */ if (textPtr->tabArrayPtr != NULL) { - ckfree((char *) textPtr->tabArrayPtr); + ckfree(textPtr->tabArrayPtr); textPtr->tabArrayPtr = NULL; } if (textPtr->tabOptionPtr != NULL) { @@ -2550,8 +2549,7 @@ InsertChars( resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - lineAndByteIndex = (int *) - ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); + lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } @@ -2613,7 +2611,7 @@ InsertChars( resetViewCount += 2; } if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - ckfree((char *) lineAndByteIndex); + ckfree(lineAndByteIndex); } /* @@ -3009,7 +3007,7 @@ DeleteIndexRange( for (i = 0; i < arraySize; i++) { TkBTreeTag(&index2, &oldIndex2, arrayPtr[i], 0); } - ckfree((char *) arrayPtr); + ckfree(arrayPtr); } } @@ -3063,8 +3061,7 @@ DeleteIndexRange( resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - lineAndByteIndex = (int *) - ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); + lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } @@ -3166,7 +3163,7 @@ DeleteIndexRange( resetViewCount += 2; } if (sharedTextPtr->refCount > PIXEL_CLIENTS) { - ckfree((char *) lineAndByteIndex); + ckfree(lineAndByteIndex); } if (line1 >= line2) { @@ -3552,7 +3549,7 @@ TextInsertCmd( for (i = 0; i < numTags; i++) { TkBTreeTag(&index1, &index2, oldTagArrayPtr[i], 0); } - ckfree((char *) oldTagArrayPtr); + ckfree(oldTagArrayPtr); } if (Tcl_ListObjGetElements(interp, objv[j+1], &numTags, &tagNamePtrs) != TCL_OK) { @@ -4327,8 +4324,8 @@ TkTextGetTabs( * Parse the elements of the list one at a time to fill in the array. */ - tabArrayPtr = (TkTextTabArray *) ckalloc((unsigned) - (sizeof(TkTextTabArray) + (count-1)*sizeof(TkTextTab))); + tabArrayPtr = ckalloc(sizeof(TkTextTabArray) + + (count - 1) * sizeof(TkTextTab)); tabArrayPtr->numTabs = 0; prevStop = 0.0; lastStop = 0.0; @@ -4427,7 +4424,7 @@ TkTextGetTabs( return tabArrayPtr; error: - ckfree((char *) tabArrayPtr); + ckfree(tabArrayPtr); return NULL; } @@ -4690,7 +4687,7 @@ DumpLine( */ int length = last - first; - char *range = ckalloc((length + 1) * sizeof(char)); + char *range = ckalloc(length + 1); memcpy(range, segPtr->body.chars + first, length * sizeof(char)); @@ -6170,13 +6167,13 @@ SearchCore( * matches on the heap. */ - int *newArray = (int *) + int *newArray = ckalloc(4 * matchNum * sizeof(int)); memcpy(newArray, storeMatch, matchNum*sizeof(int)); memcpy(newArray + 2*matchNum, storeLength, matchNum * sizeof(int)); if (storeMatch != smArray) { - ckfree((char *) storeMatch); + ckfree(storeMatch); } matchNum *= 2; storeMatch = newArray; @@ -6406,7 +6403,7 @@ SearchCore( */ if (storeMatch != smArray) { - ckfree((char *) storeMatch); + ckfree(storeMatch); } return code; diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index cd1da60..ab529a7 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -275,9 +275,9 @@ TkBTreeCreate( * of the tree. */ - rootPtr = (Node *) ckalloc(sizeof(Node)); - linePtr = (TkTextLine *) ckalloc(sizeof(TkTextLine)); - linePtr2 = (TkTextLine *) ckalloc(sizeof(TkTextLine)); + rootPtr = ckalloc(sizeof(Node)); + linePtr = ckalloc(sizeof(TkTextLine)); + linePtr2 = ckalloc(sizeof(TkTextLine)); rootPtr->parentPtr = NULL; rootPtr->nextPtr = NULL; @@ -298,7 +298,7 @@ TkBTreeCreate( linePtr->parentPtr = rootPtr; linePtr->nextPtr = linePtr2; - segPtr = (TkTextSegment *) ckalloc(CSEG_SIZE(1)); + segPtr = ckalloc(CSEG_SIZE(1)); linePtr->segPtr = segPtr; segPtr->typePtr = &tkTextCharType; segPtr->nextPtr = NULL; @@ -308,7 +308,7 @@ TkBTreeCreate( linePtr2->parentPtr = rootPtr; linePtr2->nextPtr = NULL; - segPtr = (TkTextSegment *) ckalloc(CSEG_SIZE(1)); + segPtr = ckalloc(CSEG_SIZE(1)); linePtr2->segPtr = segPtr; segPtr->typePtr = &tkTextCharType; segPtr->nextPtr = NULL; @@ -316,7 +316,7 @@ TkBTreeCreate( segPtr->body.chars[0] = '\n'; segPtr->body.chars[1] = 0; - treePtr = (BTree *) ckalloc(sizeof(BTree)); + treePtr = ckalloc(sizeof(BTree)); treePtr->sharedTextPtr = sharedTextPtr; treePtr->rootPtr = rootPtr; treePtr->clients = 0; @@ -480,10 +480,10 @@ TkBTreeDestroy( DestroyNode(treePtr->rootPtr); if (treePtr->startEnd != NULL) { - ckfree((char *) treePtr->startEnd); - ckfree((char *) treePtr->startEndRef); + ckfree(treePtr->startEnd); + ckfree(treePtr->startEndRef); } - ckfree((char *) treePtr); + ckfree(treePtr); } /* @@ -545,7 +545,7 @@ TkBTreeRemoveClient( */ DestroyNode(treePtr->rootPtr); - ckfree((char *) treePtr); + ckfree(treePtr); return; } else if (pixelReference == -1) { /* @@ -634,11 +634,9 @@ AdjustStartEndRefs( i++; } treePtr->startEndCount = count; - treePtr->startEnd = (TkTextLine **) - ckrealloc((char *) treePtr->startEnd, + treePtr->startEnd = ckrealloc(treePtr->startEnd, sizeof(TkTextLine *) * count); - treePtr->startEndRef = (TkText **) - ckrealloc((char *) treePtr->startEndRef, + treePtr->startEndRef = ckrealloc(treePtr->startEndRef, sizeof(TkText *) * count); } if ((action & TEXT_ADD_REFS) @@ -654,11 +652,9 @@ AdjustStartEndRefs( count = treePtr->startEndCount; - treePtr->startEnd = (TkTextLine **) - ckrealloc((char *) treePtr->startEnd, + treePtr->startEnd = ckrealloc(treePtr->startEnd, sizeof(TkTextLine *) * count); - treePtr->startEndRef = (TkText **) - ckrealloc((char *) treePtr->startEndRef, + treePtr->startEndRef = ckrealloc(treePtr->startEndRef, sizeof(TkText *) * count); if (textPtr->start != NULL) { @@ -741,7 +737,7 @@ AdjustPixelClient( *counting = 0; } if (newPixelReferences != treePtr->pixelReferences) { - linePtr->pixels = (int *) ckrealloc((char *) linePtr->pixels, + linePtr->pixels = ckrealloc(linePtr->pixels, sizeof(int) * 2 * newPixelReferences); } @@ -758,7 +754,7 @@ AdjustPixelClient( } } if (newPixelReferences != treePtr->pixelReferences) { - nodePtr->numPixels = (int *) ckrealloc((char *) nodePtr->numPixels, + nodePtr->numPixels = ckrealloc(nodePtr->numPixels, sizeof(int) * newPixelReferences); } nodePtr->numPixels[useReference] = pixelCount; @@ -807,7 +803,7 @@ RemovePixelClient( if (treePtr->pixelReferences == 1) { nodePtr->numPixels = NULL; } else { - nodePtr->numPixels = (int *) ckrealloc((char *) nodePtr->numPixels, + nodePtr->numPixels = ckrealloc(nodePtr->numPixels, sizeof(int) * (treePtr->pixelReferences - 1)); } if (nodePtr->level != 0) { @@ -828,7 +824,7 @@ RemovePixelClient( if (treePtr->pixelReferences == 1) { linePtr->pixels = NULL; } else { - linePtr->pixels = (int *) ckrealloc((char *) linePtr->pixels, + linePtr->pixels = ckrealloc(linePtr->pixels, sizeof(int) * 2 * (treePtr->pixelReferences-1)); } linePtr = linePtr->nextPtr; @@ -869,8 +865,8 @@ DestroyNode( linePtr->segPtr = segPtr->nextPtr; segPtr->typePtr->deleteProc(segPtr, linePtr, 1); } - ckfree((char *) linePtr->pixels); - ckfree((char *) linePtr); + ckfree(linePtr->pixels); + ckfree(linePtr); } } else { register Node *childPtr; @@ -882,8 +878,8 @@ DestroyNode( } } DeleteSummaries(nodePtr->summaryPtr); - ckfree((char *) nodePtr->numPixels); - ckfree((char *) nodePtr); + ckfree(nodePtr->numPixels); + ckfree(nodePtr); } /* @@ -912,7 +908,7 @@ DeleteSummaries( while (summaryPtr != NULL) { nextPtr = summaryPtr->nextPtr; - ckfree((char *) summaryPtr); + ckfree(summaryPtr); summaryPtr = nextPtr; } } @@ -1049,8 +1045,7 @@ TkBTreeInsertChars( changeToLineCount = 0; if (treePtr->pixelReferences > PIXEL_CLIENTS) { - changeToPixelCount = (int *) - ckalloc(sizeof(int) * treePtr->pixelReferences); + changeToPixelCount = ckalloc(sizeof(int) * treePtr->pixelReferences); } else { changeToPixelCount = pixels; } @@ -1066,7 +1061,7 @@ TkBTreeInsertChars( } } chunkSize = eol-string; - segPtr = (TkTextSegment *) ckalloc(CSEG_SIZE(chunkSize)); + segPtr = ckalloc(CSEG_SIZE(chunkSize)); segPtr->typePtr = &tkTextCharType; if (curPtr == NULL) { segPtr->nextPtr = linePtr->segPtr; @@ -1088,8 +1083,8 @@ TkBTreeInsertChars( * the remainder of the old line to it. */ - newLinePtr = (TkTextLine *) ckalloc(sizeof(TkTextLine)); - newLinePtr->pixels = (int *) + newLinePtr = ckalloc(sizeof(TkTextLine)); + newLinePtr->pixels = ckalloc(sizeof(int) * 2 * treePtr->pixelReferences); newLinePtr->parentPtr = linePtr->parentPtr; @@ -1149,7 +1144,7 @@ TkBTreeInsertChars( } } if (treePtr->pixelReferences > PIXEL_CLIENTS) { - ckfree((char *) changeToPixelCount); + ckfree(changeToPixelCount); } nodePtr = linePtr->parentPtr; @@ -1421,8 +1416,8 @@ TkBTreeDeleteIndexRange( checkCount++; } } - ckfree((char *) curLinePtr->pixels); - ckfree((char *) curLinePtr); + ckfree(curLinePtr->pixels); + ckfree(curLinePtr); } curLinePtr = nextLinePtr; segPtr = curLinePtr->segPtr; @@ -1446,7 +1441,7 @@ TkBTreeDeleteIndexRange( prevNodePtr->nextPtr = curNodePtr->nextPtr; } parentPtr->numChildren--; - ckfree((char *) curNodePtr); + ckfree(curNodePtr); curNodePtr = parentPtr; } curNodePtr = curLinePtr->parentPtr; @@ -1541,8 +1536,8 @@ TkBTreeDeleteIndexRange( checkCount++; } } - ckfree((char *) index2Ptr->linePtr->pixels); - ckfree((char *) index2Ptr->linePtr); + ckfree(index2Ptr->linePtr->pixels); + ckfree(index2Ptr->linePtr); Rebalance((BTree *) index2Ptr->tree, curNodePtr); } @@ -2137,7 +2132,7 @@ TkBTreeTag( oldState = TkBTreeCharTagged(index1Ptr, tagPtr); if ((add != 0) ^ oldState) { - segPtr = (TkTextSegment *) ckalloc(TSEG_SIZE); + segPtr = ckalloc(TSEG_SIZE); segPtr->typePtr = (add) ? &tkTextToggleOnType : &tkTextToggleOffType; prevPtr = SplitSeg(index1Ptr); if (prevPtr == NULL) { @@ -2182,7 +2177,7 @@ TkBTreeTag( } else { changed = 0; } - ckfree((char *) segPtr); + ckfree(segPtr); /* * The code below is a bit tricky. After deleting a toggle we @@ -2208,7 +2203,7 @@ TkBTreeTag( } } if ((add != 0) ^ oldState) { - segPtr = (TkTextSegment *) ckalloc(TSEG_SIZE); + segPtr = ckalloc(TSEG_SIZE); segPtr->typePtr = (add) ? &tkTextToggleOffType : &tkTextToggleOnType; prevPtr = SplitSeg(index2Ptr); if (prevPtr == NULL) { @@ -2333,7 +2328,7 @@ ChangeNodeToggleCount( } else { prevPtr->nextPtr = summaryPtr->nextPtr; } - ckfree((char *) summaryPtr); + ckfree(summaryPtr); } else { /* * This tag isn't currently in the summary information list. @@ -2352,7 +2347,7 @@ ChangeNodeToggleCount( Node *rootNodePtr = tagPtr->tagRootPtr; - summaryPtr = (Summary *) ckalloc(sizeof(Summary)); + summaryPtr = ckalloc(sizeof(Summary)); summaryPtr->tagPtr = tagPtr; summaryPtr->toggleCount = tagPtr->toggleCount - delta; summaryPtr->nextPtr = rootNodePtr->summaryPtr; @@ -2361,7 +2356,7 @@ ChangeNodeToggleCount( rootLevel = rootNodePtr->level; tagPtr->tagRootPtr = rootNodePtr; } - summaryPtr = (Summary *) ckalloc(sizeof(Summary)); + summaryPtr = ckalloc(sizeof(Summary)); summaryPtr->tagPtr = tagPtr; summaryPtr->toggleCount = delta; summaryPtr->nextPtr = nodePtr->summaryPtr; @@ -2418,7 +2413,7 @@ ChangeNodeToggleCount( } else { prevPtr->nextPtr = summaryPtr->nextPtr; } - ckfree((char *) summaryPtr); + ckfree(summaryPtr); tagPtr->tagRootPtr = node2Ptr; break; } @@ -3337,10 +3332,8 @@ TkBTreeGetTags( tagInfo.numTags = 0; tagInfo.arraySize = NUM_TAG_INFOS; - tagInfo.tagPtrs = (TkTextTag **) - ckalloc((unsigned) NUM_TAG_INFOS * sizeof(TkTextTag *)); - tagInfo.counts = (int *) - ckalloc((unsigned) NUM_TAG_INFOS * sizeof(int)); + tagInfo.tagPtrs = ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *)); + tagInfo.counts = ckalloc(NUM_TAG_INFOS * sizeof(int)); /* * Record tag toggles within the line of indexPtr but preceding indexPtr. @@ -3425,9 +3418,9 @@ TkBTreeGetTags( } } *numTagsPtr = dst; - ckfree((char *) tagInfo.counts); + ckfree(tagInfo.counts); if (dst == 0) { - ckfree((char *) tagInfo.tagPtrs); + ckfree(tagInfo.tagPtrs); return NULL; } return tagInfo.tagPtrs; @@ -3484,8 +3477,7 @@ TkTextIsElided( int elide; if (elideInfo == NULL) { - infoPtr = (TkTextElideInfo *) - ckalloc((unsigned) sizeof(TkTextElideInfo)); + infoPtr = ckalloc(sizeof(TkTextElideInfo)); } else { infoPtr = elideInfo; } @@ -3500,10 +3492,8 @@ TkTextIsElided( */ if (LOTSA_TAGS < infoPtr->numTags) { - infoPtr->tagCnts = (int *) - ckalloc((unsigned) sizeof(int) * infoPtr->numTags); - infoPtr->tagPtrs = (TkTextTag **) - ckalloc((unsigned) sizeof(TkTextTag *) * infoPtr->numTags); + infoPtr->tagCnts = ckalloc(sizeof(int) * infoPtr->numTags); + infoPtr->tagPtrs = ckalloc(sizeof(TkTextTag *) * infoPtr->numTags); } for (i=0; i<infoPtr->numTags; i++) { @@ -3632,11 +3622,11 @@ TkTextIsElided( if (elideInfo == NULL) { if (LOTSA_TAGS < infoPtr->numTags) { - ckfree((char *) infoPtr->tagCnts); - ckfree((char *) infoPtr->tagPtrs); + ckfree(infoPtr->tagCnts); + ckfree(infoPtr->tagPtrs); } - ckfree((char *) infoPtr); + ckfree(infoPtr); } return elide; @@ -3665,8 +3655,8 @@ TkTextFreeElideInfo( * structure. */ { if (LOTSA_TAGS < elideInfo->numTags) { - ckfree((char *) elideInfo->tagCnts); - ckfree((char *) elideInfo->tagPtrs); + ckfree(elideInfo->tagCnts); + ckfree(elideInfo->tagPtrs); } } @@ -3717,16 +3707,15 @@ IncCount( int *newCounts, newSize; newSize = 2 * tagInfoPtr->arraySize; - newTags = (TkTextTag **) - ckalloc((unsigned) newSize * sizeof(TkTextTag *)); + newTags = ckalloc(newSize * sizeof(TkTextTag *)); memcpy(newTags, tagInfoPtr->tagPtrs, tagInfoPtr->arraySize * sizeof(TkTextTag *)); - ckfree((char *) tagInfoPtr->tagPtrs); + ckfree(tagInfoPtr->tagPtrs); tagInfoPtr->tagPtrs = newTags; - newCounts = (int *) ckalloc((unsigned) newSize * sizeof(int)); + newCounts = ckalloc(newSize * sizeof(int)); memcpy(newCounts, tagInfoPtr->counts, tagInfoPtr->arraySize * sizeof(int)); - ckfree((char *) tagInfoPtr->counts); + ckfree(tagInfoPtr->counts); tagInfoPtr->counts = newCounts; tagInfoPtr->arraySize = newSize; } @@ -3926,7 +3915,7 @@ CheckNodeConsistency( numChildren = 0; numLines = 0; if (references > PIXEL_CLIENTS) { - numPixels = (int *) ckalloc(sizeof(int) * references); + numPixels = ckalloc(sizeof(int) * references); } else { numPixels = pixels; } @@ -4015,7 +4004,7 @@ CheckNodeConsistency( } } if (references > PIXEL_CLIENTS) { - ckfree((char *) numPixels); + ckfree(numPixels); } for (summaryPtr = nodePtr->summaryPtr; summaryPtr != NULL; @@ -4114,7 +4103,7 @@ Rebalance( */ if (nodePtr->parentPtr == NULL) { - newPtr = (Node *) ckalloc(sizeof(Node)); + newPtr = ckalloc(sizeof(Node)); newPtr->parentPtr = NULL; newPtr->nextPtr = NULL; newPtr->summaryPtr = NULL; @@ -4122,7 +4111,7 @@ Rebalance( newPtr->children.nodePtr = nodePtr; newPtr->numChildren = 1; newPtr->numLines = nodePtr->numLines; - newPtr->numPixels = (int *) + newPtr->numPixels = ckalloc(sizeof(int) * treePtr->pixelReferences); for (i=0; i<treePtr->pixelReferences; i++) { newPtr->numPixels[i] = nodePtr->numPixels[i]; @@ -4130,8 +4119,8 @@ Rebalance( RecomputeNodeCounts(treePtr, newPtr); treePtr->rootPtr = newPtr; } - newPtr = (Node *) ckalloc(sizeof(Node)); - newPtr->numPixels = (int *) + newPtr = ckalloc(sizeof(Node)); + newPtr->numPixels = ckalloc(sizeof(int) * treePtr->pixelReferences); for (i=0; i<treePtr->pixelReferences; i++) { newPtr->numPixels[i] = 0; @@ -4188,7 +4177,7 @@ Rebalance( treePtr->rootPtr = nodePtr->children.nodePtr; treePtr->rootPtr->parentPtr = NULL; DeleteSummaries(nodePtr->summaryPtr); - ckfree((char *) nodePtr); + ckfree(nodePtr); } return; } @@ -4277,7 +4266,7 @@ Rebalance( nodePtr->nextPtr = otherPtr->nextPtr; nodePtr->parentPtr->numChildren--; DeleteSummaries(otherPtr->summaryPtr); - ckfree((char *) otherPtr); + ckfree(otherPtr); continue; } @@ -4375,7 +4364,7 @@ RecomputeNodeCounts( for (summaryPtr = nodePtr->summaryPtr; ; summaryPtr = summaryPtr->nextPtr) { if (summaryPtr == NULL) { - summaryPtr = (Summary *) ckalloc(sizeof(Summary)); + summaryPtr = ckalloc(sizeof(Summary)); summaryPtr->tagPtr = tagPtr; summaryPtr->toggleCount = 1; summaryPtr->nextPtr = nodePtr->summaryPtr; @@ -4403,7 +4392,7 @@ RecomputeNodeCounts( for (summaryPtr = nodePtr->summaryPtr; ; summaryPtr = summaryPtr->nextPtr) { if (summaryPtr == NULL) { - summaryPtr = (Summary *) ckalloc(sizeof(Summary)); + summaryPtr = ckalloc(sizeof(Summary)); summaryPtr->tagPtr = summaryPtr2->tagPtr; summaryPtr->toggleCount = summaryPtr2->toggleCount; summaryPtr->nextPtr = nodePtr->summaryPtr; @@ -4452,11 +4441,11 @@ RecomputeNodeCounts( } if (summaryPtr2 != NULL) { summaryPtr2->nextPtr = summaryPtr->nextPtr; - ckfree((char *) summaryPtr); + ckfree(summaryPtr); summaryPtr = summaryPtr2->nextPtr; } else { nodePtr->summaryPtr = summaryPtr->nextPtr; - ckfree((char *) summaryPtr); + ckfree(summaryPtr); summaryPtr = nodePtr->summaryPtr; } } @@ -4556,9 +4545,8 @@ CharSplitProc( { TkTextSegment *newPtr1, *newPtr2; - newPtr1 = (TkTextSegment *) ckalloc(CSEG_SIZE(index)); - newPtr2 = (TkTextSegment *) ckalloc( - CSEG_SIZE(segPtr->size - index)); + newPtr1 = ckalloc(CSEG_SIZE(index)); + newPtr2 = ckalloc(CSEG_SIZE(segPtr->size - index)); newPtr1->typePtr = &tkTextCharType; newPtr1->nextPtr = newPtr2; newPtr1->size = index; @@ -4568,7 +4556,7 @@ CharSplitProc( newPtr2->nextPtr = segPtr->nextPtr; newPtr2->size = segPtr->size - index; strcpy(newPtr2->body.chars, segPtr->body.chars + index); - ckfree((char *) segPtr); + ckfree(segPtr); return newPtr1; } @@ -4603,15 +4591,14 @@ CharCleanupProc( if ((segPtr2 == NULL) || (segPtr2->typePtr != &tkTextCharType)) { return segPtr; } - newPtr = (TkTextSegment *) ckalloc(CSEG_SIZE( - segPtr->size + segPtr2->size)); + newPtr = ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size)); newPtr->typePtr = &tkTextCharType; newPtr->nextPtr = segPtr2->nextPtr; newPtr->size = segPtr->size + segPtr2->size; strcpy(newPtr->body.chars, segPtr->body.chars); strcpy(newPtr->body.chars + segPtr->size, segPtr2->body.chars); - ckfree((char *) segPtr); - ckfree((char *) segPtr2); + ckfree(segPtr); + ckfree(segPtr2); return newPtr; } @@ -4640,7 +4627,7 @@ CharDeleteProc( * deleted, so everything must get cleaned * up. */ { - ckfree((char *) segPtr); + ckfree(segPtr); return 0; } @@ -4716,7 +4703,7 @@ ToggleDeleteProc( * up. */ { if (treeGone) { - ckfree((char *) segPtr); + ckfree(segPtr); return 0; } @@ -4790,9 +4777,9 @@ ToggleCleanupProc( segPtr->body.toggle.tagPtr, -counts); } prevPtr->nextPtr = segPtr2->nextPtr; - ckfree((char *) segPtr2); + ckfree(segPtr2); segPtr2 = segPtr->nextPtr; - ckfree((char *) segPtr); + ckfree(segPtr); return segPtr2; } } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 849123f..b287a94 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -626,7 +626,7 @@ TkTextCreateDInfo( register TextDInfo *dInfoPtr; XGCValues gcValues; - dInfoPtr = (TextDInfo *) ckalloc(sizeof(TextDInfo)); + dInfoPtr = ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; dInfoPtr->copyGC = None; @@ -719,7 +719,7 @@ TkTextFreeDInfo( textPtr->refCount--; dInfoPtr->scrollbarTimer = NULL; } - ckfree((char *) dInfoPtr); + ckfree(dInfoPtr); } /* @@ -923,7 +923,7 @@ GetStyle( } } if (tagPtrs != NULL) { - ckfree((char *) tagPtrs); + ckfree(tagPtrs); } /* @@ -942,7 +942,7 @@ GetStyle( * No existing style matched. Make a new one. */ - stylePtr = (TextStyle *) ckalloc(sizeof(TextStyle)); + stylePtr = ckalloc(sizeof(TextStyle)); stylePtr->refCount = 1; if (styleValues.border != NULL) { gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel; @@ -1007,7 +1007,7 @@ FreeStyle( Tk_FreeGC(textPtr->display, stylePtr->fgGC); } Tcl_DeleteHashEntry(stylePtr->hPtr); - ckfree((char *) stylePtr); + ckfree(stylePtr); } } @@ -1106,7 +1106,7 @@ LayoutDLine( * Create and initialize a new DLine structure. */ - dlPtr = (DLine *) ckalloc(sizeof(DLine)); + dlPtr = ckalloc(sizeof(DLine)); dlPtr->index = *indexPtr; dlPtr->byteCount = 0; dlPtr->y = 0; @@ -1337,7 +1337,7 @@ LayoutDLine( * into a single display line. * if (segPtr == NULL && chunkPtr != NULL) { - ckfree((char *) chunkPtr); + ckfree(chunkPtr); chunkPtr = NULL; } */ @@ -1351,7 +1351,7 @@ LayoutDLine( continue; } if (chunkPtr == NULL) { - chunkPtr = (TkTextDispChunk *) ckalloc(sizeof(TkTextDispChunk)); + chunkPtr = ckalloc(sizeof(TkTextDispChunk)); chunkPtr->nextPtr = NULL; chunkPtr->clientData = NULL; } @@ -1483,7 +1483,7 @@ LayoutDLine( */ if (chunkPtr != NULL) { - ckfree((char *) chunkPtr); + ckfree(chunkPtr); } break; } @@ -1614,7 +1614,7 @@ LayoutDLine( if (chunkPtr->undisplayProc != NULL) { chunkPtr->undisplayProc(textPtr, chunkPtr); } - ckfree((char *) chunkPtr); + ckfree(chunkPtr); } if (breakByteOffset != breakChunkPtr->numBytes) { if (breakChunkPtr->undisplayProc != NULL) { @@ -2311,9 +2311,9 @@ FreeDLines( } FreeStyle(textPtr, chunkPtr->stylePtr); nextChunkPtr = chunkPtr->nextPtr; - ckfree((char *) chunkPtr); + ckfree(chunkPtr); } - ckfree((char *) firstPtr); + ckfree(firstPtr); firstPtr = nextDLinePtr; } if (action != DLINE_FREE_TEMP) { @@ -2891,7 +2891,7 @@ AsyncUpdateLineMetrics( */ if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } return; } @@ -2943,7 +2943,7 @@ AsyncUpdateLineMetrics( textPtr->refCount--; if (textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } return; } @@ -3954,7 +3954,7 @@ DisplayText( dInfoPtr->flags &= ~REPICK_NEEDED; TkTextPickCurrent(textPtr, &textPtr->pickEvent); if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); goto end; } if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { @@ -6387,7 +6387,7 @@ AsyncUpdateYScrollbar( } if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } } @@ -7072,7 +7072,7 @@ TkTextCharLayoutProc( #if TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr == NULL) { baseCharChunkPtr = chunkPtr; - bciPtr = (BaseCharInfo *) ckalloc(sizeof(BaseCharInfo)); + bciPtr = ckalloc(sizeof(BaseCharInfo)); baseString = &bciPtr->baseChars; Tcl_DStringInit(baseString); bciPtr->width = 0; @@ -7080,7 +7080,7 @@ TkTextCharLayoutProc( ciPtr = &bciPtr->ci; } else { bciPtr = baseCharChunkPtr->clientData; - ciPtr = (CharInfo *) ckalloc(sizeof(CharInfo)); + ciPtr = ckalloc(sizeof(CharInfo)); baseString = &bciPtr->baseChars; } @@ -7143,7 +7143,7 @@ TkTextCharLayoutProc( } else { Tcl_DStringSetLength(baseString,lineOffset); } - ckfree((char *) ciPtr); + ckfree(ciPtr); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ return 0; } @@ -7169,8 +7169,7 @@ TkTextCharLayoutProc( chunkPtr->breakIndex = -1; #if !TK_LAYOUT_WITH_BASE_CHUNKS - ciPtr = (CharInfo *) - ckalloc((unsigned) ((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit)); + ciPtr = ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit); chunkPtr->clientData = ciPtr; memcpy(ciPtr->chars, p, (unsigned) bytesThatFit); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ @@ -7550,7 +7549,7 @@ CharUndisplayProc( ciPtr->numBytes = 0; #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ - ckfree((char *) ciPtr); + ckfree(ciPtr); chunkPtr->clientData = NULL; } } diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index 7f1ce25..ac1ca63 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -239,7 +239,7 @@ TkTextImageCmd( * Create the new image segment and initialize it. */ - eiPtr = (TkTextSegment *) ckalloc(EI_SEG_SIZE); + eiPtr = ckalloc(EI_SEG_SIZE); eiPtr->typePtr = &tkTextEmbImageType; eiPtr->size = 1; eiPtr->body.ei.sharedTextPtr = textPtr->sharedTextPtr; @@ -413,7 +413,7 @@ EmbImageConfigure( } Tcl_SetHashValue(hPtr, eiPtr); Tcl_AppendResult(textPtr->interp, name, NULL); - eiPtr->body.ei.name = ckalloc((unsigned) Tcl_DStringLength(&newName)+1); + eiPtr->body.ei.name = ckalloc(Tcl_DStringLength(&newName) + 1); strcpy(eiPtr->body.ei.name, name); Tcl_DStringFree(&newName); @@ -474,7 +474,7 @@ EmbImageDeleteProc( if (eiPtr->body.ei.name) { ckfree(eiPtr->body.ei.name); } - ckfree((char *) eiPtr); + ckfree(eiPtr); return 0; } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index e192962..aaabb88 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -92,10 +92,10 @@ FreeTextIndexInternalRep( * The text widget has been deleted and we need to free it now. */ - ckfree((char *) indexPtr->textPtr); + ckfree(indexPtr->textPtr); } } - ckfree((char *) indexPtr); + ckfree(indexPtr); indexObjPtr->typePtr = NULL; } @@ -107,7 +107,7 @@ DupTextIndexInternalRep( int epoch; TkTextIndex *dupIndexPtr, *indexPtr; - dupIndexPtr = (TkTextIndex *) ckalloc(sizeof(TkTextIndex)); + dupIndexPtr = ckalloc(sizeof(TkTextIndex)); indexPtr = GET_TEXTINDEX(srcPtr); epoch = GET_INDEXEPOCH(srcPtr); @@ -140,7 +140,7 @@ UpdateStringOfTextIndex( len = TkTextPrintIndex(indexPtr->textPtr, indexPtr, buffer); - objPtr->bytes = ckalloc((unsigned) len + 1); + objPtr->bytes = ckalloc(len + 1); strcpy(objPtr->bytes, buffer); objPtr->length = len; } @@ -187,7 +187,7 @@ MakeObjIndex( * position. */ const TkTextIndex *origPtr) /* Pointer to index. */ { - TkTextIndex *indexPtr = (TkTextIndex *) ckalloc(sizeof(TkTextIndex)); + TkTextIndex *indexPtr = ckalloc(sizeof(TkTextIndex)); indexPtr->tree = origPtr->tree; indexPtr->linePtr = origPtr->linePtr; @@ -1486,7 +1486,7 @@ TkTextIndexForwChars( return; } if (checkElided) { - infoPtr = (TkTextElideInfo *) ckalloc(sizeof(TkTextElideInfo)); + infoPtr = ckalloc(sizeof(TkTextElideInfo)); elide = TkTextIsElided(textPtr, srcPtr, infoPtr); } @@ -1614,7 +1614,7 @@ TkTextIndexForwChars( forwardCharDone: if (infoPtr != NULL) { TkTextFreeElideInfo(infoPtr); - ckfree((char *) infoPtr); + ckfree(infoPtr); } } @@ -1670,7 +1670,7 @@ TkTextIndexCount( seg2Ptr = TkTextIndexToSeg(indexPtr2, &maxBytes); if (checkElided) { - infoPtr = (TkTextElideInfo *) ckalloc(sizeof(TkTextElideInfo)); + infoPtr = ckalloc(sizeof(TkTextElideInfo)); elide = TkTextIsElided(textPtr, indexPtr1, infoPtr); } @@ -1810,7 +1810,7 @@ TkTextIndexCount( countDone: if (infoPtr != NULL) { TkTextFreeElideInfo(infoPtr); - ckfree((char *) infoPtr); + ckfree(infoPtr); } return count; } @@ -1928,7 +1928,7 @@ TkTextIndexBackChars( return; } if (checkElided) { - infoPtr = (TkTextElideInfo *) ckalloc(sizeof(TkTextElideInfo)); + infoPtr = ckalloc(sizeof(TkTextElideInfo)); elide = TkTextIsElided(textPtr, srcPtr, infoPtr); } @@ -2094,7 +2094,7 @@ TkTextIndexBackChars( backwardCharDone: if (infoPtr != NULL) { TkTextFreeElideInfo(infoPtr); - ckfree((char *) infoPtr); + ckfree(infoPtr); } } diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c index 4fe035d..8a624d2 100644 --- a/generic/tkTextMark.c +++ b/generic/tkTextMark.c @@ -228,7 +228,7 @@ TkTextMarkCmd( } TkBTreeUnlinkSegment(markPtr, markPtr->body.mark.linePtr); Tcl_DeleteHashEntry(hPtr); - ckfree((char *) markPtr); + ckfree(markPtr); } } break; @@ -307,7 +307,7 @@ TkTextSetMark( } TkBTreeUnlinkSegment(markPtr, markPtr->body.mark.linePtr); } else { - markPtr = (TkTextSegment *) ckalloc(MSEG_SIZE); + markPtr = ckalloc(MSEG_SIZE); markPtr->typePtr = &tkTextRightMarkType; markPtr->size = 0; markPtr->body.mark.textPtr = textPtr; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 95fccb7..cf3b0c6 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -438,7 +438,7 @@ TkTextTagCmd( } } if (tagPtr->tabArrayPtr != NULL) { - ckfree((char *) tagPtr->tabArrayPtr); + ckfree(tagPtr->tabArrayPtr); tagPtr->tabArrayPtr = NULL; } if (tagPtr->tabStringPtr != NULL) { @@ -602,8 +602,8 @@ TkTextTagCmd( Tcl_HashSearch search; Tcl_HashEntry *hPtr; - arrayPtr = (TkTextTag **) ckalloc((unsigned) - (textPtr->sharedTextPtr->numTags * sizeof(TkTextTag *))); + arrayPtr = ckalloc(textPtr->sharedTextPtr->numTags + * sizeof(TkTextTag *)); for (i=0, hPtr = Tcl_FirstHashEntry( &textPtr->sharedTextPtr->tagTable, &search); hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) { @@ -636,7 +636,7 @@ TkTextTagCmd( Tcl_NewStringObj(tagPtr->name,-1)); } Tcl_SetObjResult(interp, listObj); - ckfree((char *) arrayPtr); + ckfree(arrayPtr); break; } case TAG_NEXTRANGE: { @@ -965,7 +965,7 @@ TkTextCreateTag( * to it to the hash table entry. */ - tagPtr = (TkTextTag *) ckalloc(sizeof(TkTextTag)); + tagPtr = ckalloc(sizeof(TkTextTag)); tagPtr->name = name; tagPtr->textPtr = NULL; tagPtr->toggleCount = 0; @@ -1169,7 +1169,7 @@ TkTextFreeTag( */ if (tagPtr->tabArrayPtr != NULL) { - ckfree((char *) tagPtr->tabArrayPtr); + ckfree(tagPtr->tabArrayPtr); } /* @@ -1198,7 +1198,7 @@ TkTextFreeTag( } textPtr->refCount--; if (textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } tagPtr->textPtr = NULL; } @@ -1207,7 +1207,7 @@ TkTextFreeTag( * Finally free the tag's memory. */ - ckfree((char *) tagPtr); + ckfree(tagPtr); } /* @@ -1461,7 +1461,7 @@ TkTextBindProc( done: if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); + ckfree(textPtr); } } @@ -1593,7 +1593,7 @@ TkTextPickCurrent( SortTags(textPtr->numCurTags, textPtr->curTagArrayPtr); if (numNewTags > 0) { size = numNewTags * sizeof(TkTextTag *); - copyArrayPtr = (TkTextTag **) ckalloc((unsigned) size); + copyArrayPtr = ckalloc(size); memcpy(copyArrayPtr, newArrayPtr, (size_t) size); for (i = 0; i < textPtr->numCurTags; i++) { for (j = 0; j < numNewTags; j++) { @@ -1635,7 +1635,7 @@ TkTextPickCurrent( event.xcrossing.detail = NotifyAncestor; TagBindEvent(textPtr, &event, numOldTags, oldArrayPtr); } - ckfree((char *) oldArrayPtr); + ckfree(oldArrayPtr); } /* @@ -1657,7 +1657,7 @@ TkTextPickCurrent( event.xcrossing.detail = NotifyAncestor; TagBindEvent(textPtr, &event, numNewTags, copyArrayPtr); } - ckfree((char *) copyArrayPtr); + ckfree(copyArrayPtr); } } @@ -1697,7 +1697,7 @@ TagBindEvent( */ if (numTags > NUM_BIND_TAGS) { - nameArrPtr = (const char **) ckalloc(numTags * sizeof(const char *)); + nameArrPtr = ckalloc(numTags * sizeof(const char *)); } else { nameArrPtr = nameArray; } @@ -1710,6 +1710,7 @@ TagBindEvent( for (i = 0; i < numTags; i++) { TkTextTag *tagPtr = tagArrayPtr[i]; + if (tagPtr != NULL) { nameArrPtr[i] = tagPtr->name; } else { @@ -1726,7 +1727,7 @@ TagBindEvent( textPtr->tkwin, numTags, (ClientData *) nameArrPtr); if (numTags > NUM_BIND_TAGS) { - ckfree((char *) nameArrPtr); + ckfree(nameArrPtr); } } diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index 8c032c6..e3894fc 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -288,7 +288,7 @@ TkTextWindowCmd( * Create the new window segment and initialize it. */ - ewPtr = (TkTextSegment *) ckalloc(EW_SEG_SIZE); + ewPtr = ckalloc(EW_SEG_SIZE); ewPtr->typePtr = &tkTextEmbWindowType; ewPtr->size = 1; ewPtr->body.ew.sharedTextPtr = textPtr->sharedTextPtr; @@ -300,8 +300,7 @@ TkTextWindowCmd( ewPtr->body.ew.stretch = 0; ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs); - client = (TkTextEmbWindowClient *) - ckalloc(sizeof(TkTextEmbWindowClient)); + client = ckalloc(sizeof(TkTextEmbWindowClient)); client->next = NULL; client->textPtr = textPtr; client->tkwin = NULL; @@ -459,8 +458,7 @@ EmbWinConfigure( * Have to make the new client. */ - client = (TkTextEmbWindowClient *) - ckalloc(sizeof(TkTextEmbWindowClient)); + client = ckalloc(sizeof(TkTextEmbWindowClient)); client->next = ewPtr->body.ew.clients; client->textPtr = textPtr; client->tkwin = NULL; @@ -642,7 +640,7 @@ EmbWinLostSlaveProc( } loop->next = client->next; } - ckfree((char *) client); + ckfree(client); index.tree = ewPtr->body.ew.sharedTextPtr->tree; index.linePtr = ewPtr->body.ew.linePtr; @@ -708,7 +706,7 @@ TkTextWinFreeClient( * Free up this client. */ - ckfree((char *) client); + ckfree(client); } /* @@ -762,7 +760,7 @@ EmbWinDeleteProc( * Free up all memory allocated. */ - ckfree((char *) ewPtr); + ckfree(ewPtr); return 0; } @@ -947,8 +945,7 @@ EmbWinLayoutProc( * now need to add to our client list. */ - client = (TkTextEmbWindowClient *) - ckalloc(sizeof(TkTextEmbWindowClient)); + client = ckalloc(sizeof(TkTextEmbWindowClient)); client->next = ewPtr->body.ew.clients; client->textPtr = textPtr; client->tkwin = NULL; diff --git a/generic/tkUndo.c b/generic/tkUndo.c index 1150cef..2c56c05 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -96,7 +96,7 @@ TkUndoInsertSeparator( TkUndoAtom *separator; if (*stack!=NULL && (*stack)->type!=TK_UNDO_SEPARATOR) { - separator = (TkUndoAtom *) ckalloc(sizeof(TkUndoAtom)); + separator = ckalloc(sizeof(TkUndoAtom)); separator->type = TK_UNDO_SEPARATOR; TkUndoPushStack(stack,separator); return 1; @@ -137,7 +137,7 @@ TkUndoClearStack( if (sub->action != NULL) { Tcl_DecrRefCount(sub->action); } - ckfree((char *)sub); + ckfree(sub); sub = next; } @@ -148,11 +148,11 @@ TkUndoClearStack( if (sub->action != NULL) { Tcl_DecrRefCount(sub->action); } - ckfree((char *)sub); + ckfree(sub); sub = next; } } - ckfree((char *)elem); + ckfree(elem); } *stack = NULL; } @@ -183,7 +183,7 @@ TkUndoPushAction( { TkUndoAtom *atom; - atom = (TkUndoAtom *) ckalloc(sizeof(TkUndoAtom)); + atom = ckalloc(sizeof(TkUndoAtom)); atom->type = TK_UNDO_ACTION; atom->apply = apply; atom->revert = revert; @@ -239,7 +239,7 @@ TkUndoMakeCmdSubAtom( Tcl_Panic("NULL command and actionScript in TkUndoMakeCmdSubAtom"); } - atom = (TkUndoSubAtom *) ckalloc(sizeof(TkUndoSubAtom)); + atom = ckalloc(sizeof(TkUndoSubAtom)); atom->command = command; atom->funcPtr = NULL; atom->clientData = NULL; @@ -301,7 +301,7 @@ TkUndoMakeSubAtom( Tcl_Panic("NULL funcPtr in TkUndoMakeSubAtom"); } - atom = (TkUndoSubAtom *) ckalloc(sizeof(TkUndoSubAtom)); + atom = ckalloc(sizeof(TkUndoSubAtom)); atom->command = NULL; atom->funcPtr = funcPtr; atom->clientData = clientData; @@ -343,7 +343,7 @@ TkUndoInitStack( { TkUndoRedoStack *stack; /* An Undo/Redo stack */ - stack = (TkUndoRedoStack *) ckalloc(sizeof(TkUndoRedoStack)); + stack = ckalloc(sizeof(TkUndoRedoStack)); stack->undoStack = NULL; stack->redoStack = NULL; stack->interp = interp; @@ -406,7 +406,7 @@ TkUndoSetDepth( if (sub->action != NULL) { Tcl_DecrRefCount(sub->action); } - ckfree((char *)sub); + ckfree(sub); sub = next; } sub = elem->revert; @@ -416,12 +416,12 @@ TkUndoSetDepth( if (sub->action != NULL) { Tcl_DecrRefCount(sub->action); } - ckfree((char *)sub); + ckfree(sub); sub = next; } } elem = elem->next; - ckfree((char *) prevelem); + ckfree(prevelem); } stack->depth = stack->maxdepth; } @@ -474,7 +474,7 @@ TkUndoFreeStack( TkUndoRedoStack *stack) /* An Undo/Redo stack */ { TkUndoClearStacks(stack); - ckfree((char *) stack); + ckfree(stack); } /* @@ -543,7 +543,7 @@ TkUndoRevert( } if (elem->type == TK_UNDO_SEPARATOR) { - ckfree((char *) elem); + ckfree(elem); elem = TkUndoPopStack(&stack->undoStack); } @@ -605,7 +605,7 @@ TkUndoApply( } if (elem->type == TK_UNDO_SEPARATOR) { - ckfree((char *) elem); + ckfree(elem); elem = TkUndoPopStack(&stack->redoStack); } diff --git a/generic/tkVisual.c b/generic/tkVisual.c index 8665636..8b43e6e 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -327,7 +327,7 @@ Tk_GetVisual( goto done; } } - cmapPtr = (TkColormap *) ckalloc(sizeof(TkColormap)); + cmapPtr = ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), visual, AllocNone); @@ -382,7 +382,7 @@ Tk_GetColormap( */ if (strcmp(string, "new") == 0) { - cmapPtr = (TkColormap *) ckalloc(sizeof(TkColormap)); + cmapPtr = ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), Tk_Visual(tkwin), AllocNone); @@ -481,7 +481,7 @@ Tk_FreeColormap( } else { prevPtr->nextPtr = cmapPtr->nextPtr; } - ckfree((char *) cmapPtr); + ckfree(cmapPtr); } return; } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 508c961..528fc87 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -294,7 +294,7 @@ TkCloseDisplay( errorPtr != NULL; errorPtr = dispPtr->errorPtr) { dispPtr->errorPtr = errorPtr->nextPtr; - ckfree((char *) errorPtr); + ckfree(errorPtr); } } @@ -309,7 +309,7 @@ TkCloseDisplay( Tcl_DeleteHashTable(&dispPtr->winTable); - ckfree((char *) dispPtr); + ckfree(dispPtr); /* * There is more to clean up, we leave it at this for the time being. @@ -520,7 +520,7 @@ GetScreen( Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS); - dispPtr->name = (char *) ckalloc((unsigned) (length+1)); + dispPtr->name = ckalloc(length + 1); strncpy(dispPtr->name, screenName, length); dispPtr->name[length] = '\0'; break; @@ -654,9 +654,8 @@ TkAllocWindow( * inherit visual information. NULL means use * screen defaults instead of inheriting. */ { - register TkWindow *winPtr; + register TkWindow *winPtr = ckalloc(sizeof(TkWindow)); - winPtr = (TkWindow *) ckalloc(sizeof(TkWindow)); winPtr->display = dispPtr->display; winPtr->dispPtr = dispPtr; winPtr->screenNum = screenNum; @@ -803,7 +802,7 @@ NameWindow( if ((length1+length2+2) <= FIXED_SIZE) { pathName = staticSpace; } else { - pathName = (char *) ckalloc((unsigned) (length1+length2+2)); + pathName = ckalloc(length1 + length2 + 2); } if (length1 == 1) { pathName[0] = '.'; @@ -895,7 +894,7 @@ TkCreateMainWindow( */ winPtr = (TkWindow *) tkwin; - mainPtr = (TkMainInfo *) ckalloc(sizeof(TkMainInfo)); + mainPtr = ckalloc(sizeof(TkMainInfo)); mainPtr->winPtr = winPtr; mainPtr->refCount = 1; mainPtr->interp = interp; @@ -1178,7 +1177,7 @@ Tk_CreateWindowFromPath( } numChars = (int) (p-pathName); if (numChars > FIXED_SPACE) { - p = (char *) ckalloc((unsigned) (numChars+1)); + p = ckalloc(numChars + 1); } else { p = fixedSpace; } @@ -1285,7 +1284,7 @@ Tk_DestroyWindow( (tsdPtr->halfdeadWindowList->winPtr == winPtr)) { halfdeadPtr = tsdPtr->halfdeadWindowList; } else { - halfdeadPtr = (TkHalfdeadWindow *) ckalloc(sizeof(TkHalfdeadWindow)); + halfdeadPtr = ckalloc(sizeof(TkHalfdeadWindow)); halfdeadPtr->flags = 0; halfdeadPtr->winPtr = winPtr; halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList; @@ -1429,7 +1428,7 @@ Tk_DestroyWindow( } else { prev_halfdeadPtr->nextPtr = halfdeadPtr->nextPtr; } - ckfree((char *) halfdeadPtr); + ckfree(halfdeadPtr); break; } prev_halfdeadPtr = halfdeadPtr; @@ -1554,7 +1553,7 @@ Tk_DestroyWindow( if (winPtr->flags & TK_EMBEDDED) { XSync(winPtr->display, False); } - ckfree((char *) winPtr->mainPtr); + ckfree(winPtr->mainPtr); /* * If no other applications are using the display, close the @@ -3230,7 +3229,7 @@ Initialize( Tcl_MutexUnlock(&windowMutex); if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } code = TkpInit(interp); if (code == TCL_OK) { @@ -3269,7 +3268,7 @@ tkInit"); done: Tcl_MutexUnlock(&windowMutex); if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } return code; } diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c index 2476fcd..3829619 100644 --- a/generic/ttk/ttkBlink.c +++ b/generic/ttk/ttkBlink.c @@ -51,10 +51,10 @@ static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp) static CursorManager *GetCursorManager(Tcl_Interp *interp) { static const char *cm_key = "ttk::CursorManager"; - CursorManager *cm = (CursorManager *) Tcl_GetAssocData(interp, cm_key,0); + CursorManager *cm = Tcl_GetAssocData(interp, cm_key,0); if (!cm) { - cm = (CursorManager*)ckalloc(sizeof(*cm)); + cm = ckalloc(sizeof(*cm)); cm->timer = 0; cm->owner = 0; cm->onTime = DEF_CURSOR_ON_TIME; diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c index 8bb54ec..9163beb 100644 --- a/generic/ttk/ttkCache.c +++ b/generic/ttk/ttkCache.c @@ -50,7 +50,7 @@ struct Ttk_ResourceCache_ { */ Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *interp) { - Ttk_ResourceCache cache = (Ttk_ResourceCache)ckalloc(sizeof(*cache)); + Ttk_ResourceCache cache = ckalloc(sizeof(*cache)); cache->tkwin = NULL; /* initialized later */ cache->interp = interp; @@ -161,7 +161,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache) } Tcl_DeleteHashTable(&cache->namedColors); - ckfree((ClientData)cache); + ckfree(cache); } /* diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c index 6f84d9a..e9428ec 100644 --- a/generic/ttk/ttkImage.c +++ b/generic/ttk/ttkImage.c @@ -47,7 +47,7 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) int i = 0, n = 0, objc; Tcl_Obj **objv; - imageSpec = (Ttk_ImageSpec *)ckalloc(sizeof(*imageSpec)); + imageSpec = ckalloc(sizeof(*imageSpec)); imageSpec->baseImage = 0; imageSpec->mapCount = 0; imageSpec->states = 0; @@ -67,8 +67,8 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } n = (objc - 1) / 2; - imageSpec->states = (Ttk_StateSpec*)ckalloc(n * sizeof(Ttk_StateSpec)); - imageSpec->images = (Tk_Image*)ckalloc(n * sizeof(Tk_Image *)); + imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec)); + imageSpec->images = ckalloc(n * sizeof(Tk_Image *)); /* Get base image: */ @@ -117,10 +117,10 @@ void TtkFreeImageSpec(Ttk_ImageSpec *imageSpec) } if (imageSpec->baseImage) { Tk_FreeImage(imageSpec->baseImage); } - if (imageSpec->states) { ckfree((ClientData)imageSpec->states); } - if (imageSpec->images) { ckfree((ClientData)imageSpec->images); } + if (imageSpec->states) { ckfree(imageSpec->states); } + if (imageSpec->images) { ckfree(imageSpec->images); } - ckfree((ClientData)imageSpec); + ckfree(imageSpec); } /* TtkSelectImage -- @@ -333,7 +333,7 @@ Ttk_CreateImageElement( return TCL_ERROR; } - imageData = (ImageData*)ckalloc(sizeof(*imageData)); + imageData = ckalloc(sizeof(*imageData)); imageData->imageSpec = imageSpec; imageData->minWidth = imageData->minHeight = -1; imageData->sticky = TTK_FILL_BOTH; diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index e3f6a02..6eaf6bb 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -526,7 +526,7 @@ struct Ttk_LayoutNode_ static Ttk_LayoutNode *Ttk_NewLayoutNode( unsigned flags, Ttk_ElementClass *elementClass) { - Ttk_LayoutNode *node = (Ttk_LayoutNode*)ckalloc(sizeof(*node)); + Ttk_LayoutNode *node = ckalloc(sizeof(*node)); node->flags = flags; node->eclass = elementClass; @@ -542,7 +542,7 @@ static void Ttk_FreeLayoutNode(Ttk_LayoutNode *node) while (node) { Ttk_LayoutNode *next = node->next; Ttk_FreeLayoutNode(node->child); - ckfree((ClientData)node); + ckfree(node); node = next; } } @@ -559,7 +559,7 @@ struct Ttk_TemplateNode_ { static Ttk_TemplateNode *Ttk_NewTemplateNode(const char *name, unsigned flags) { - Ttk_TemplateNode *op = (Ttk_TemplateNode*)ckalloc(sizeof(*op)); + Ttk_TemplateNode *op = ckalloc(sizeof(*op)); op->name = ckalloc(strlen(name) + 1); strcpy(op->name, name); op->flags = flags; op->next = op->child = 0; @@ -572,7 +572,7 @@ void Ttk_FreeLayoutTemplate(Ttk_LayoutTemplate op) Ttk_LayoutTemplate next = op->next; Ttk_FreeLayoutTemplate(op->child); ckfree(op->name); - ckfree((ClientData)op); + ckfree(op); op = next; } } @@ -841,7 +841,7 @@ static Ttk_Layout TTKNewLayout( void *recordPtr,Tk_OptionTable optionTable, Tk_Window tkwin, Ttk_LayoutNode *root) { - Ttk_Layout layout = (Ttk_Layout)ckalloc(sizeof(*layout)); + Ttk_Layout layout = ckalloc(sizeof(*layout)); layout->style = style; layout->recordPtr = recordPtr; layout->optionTable = optionTable; @@ -853,7 +853,7 @@ static Ttk_Layout TTKNewLayout( void Ttk_FreeLayout(Ttk_Layout layout) { Ttk_FreeLayoutNode(layout->root); - ckfree((ClientData)layout); + ckfree(layout); } /* diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index 1238638..cd10711 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -189,7 +189,7 @@ static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr) static Ttk_Slave *NewSlave( Ttk_Manager *mgr, Tk_Window slaveWindow, void *slaveData) { - Ttk_Slave *slave = (Ttk_Slave*)ckalloc(sizeof(*slave)); + Ttk_Slave *slave = ckalloc(sizeof(*slave)); slave->slaveWindow = slaveWindow; slave->manager = mgr; @@ -201,7 +201,7 @@ static Ttk_Slave *NewSlave( static void DeleteSlave(Ttk_Slave *slave) { - ckfree((ClientData)slave); + ckfree(slave); } /*------------------------------------------------------------------------ @@ -211,7 +211,7 @@ static void DeleteSlave(Ttk_Slave *slave) Ttk_Manager *Ttk_CreateManager( Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window masterWindow) { - Ttk_Manager *mgr = (Ttk_Manager*)ckalloc(sizeof(*mgr)); + Ttk_Manager *mgr = ckalloc(sizeof(*mgr)); mgr->managerSpec = managerSpec; mgr->managerData = managerData; @@ -235,12 +235,12 @@ void Ttk_DeleteManager(Ttk_Manager *mgr) Ttk_ForgetSlave(mgr, mgr->nSlaves - 1); } if (mgr->slaves) { - ckfree((ClientData)mgr->slaves); + ckfree(mgr->slaves); } Tk_CancelIdleCall(ManagerIdleProc, mgr); - ckfree((ClientData)mgr); + ckfree(mgr); } /*------------------------------------------------------------------------ @@ -253,8 +253,7 @@ void Ttk_DeleteManager(Ttk_Manager *mgr) static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index) { int endIndex = mgr->nSlaves++; - mgr->slaves = (Ttk_Slave**)ckrealloc( - (ClientData)mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *)); + mgr->slaves = ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *)); while (endIndex > index) { mgr->slaves[endIndex] = mgr->slaves[endIndex - 1]; diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c index dc9317e..a25a2f3 100644 --- a/generic/ttk/ttkScroll.c +++ b/generic/ttk/ttkScroll.c @@ -56,7 +56,7 @@ struct ScrollHandleRec */ ScrollHandle TtkCreateScrollHandle(WidgetCore *corePtr, Scrollable *scrollPtr) { - ScrollHandle h = (ScrollHandle)ckalloc(sizeof(*h)); + ScrollHandle h = ckalloc(sizeof(*h)); h->flags = 0; h->corePtr = corePtr; @@ -248,6 +248,6 @@ void TtkFreeScrollHandle(ScrollHandle h) if (h->flags & SCROLL_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateScrollbarBG, (ClientData)h); } - ckfree((ClientData)h); + ckfree(h); } diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c index dbf6a5c..84e9ea2 100644 --- a/generic/ttk/ttkTagSet.c +++ b/generic/ttk/ttkTagSet.c @@ -35,7 +35,7 @@ struct TtkTagTable { */ static Ttk_Tag NewTag(Ttk_TagTable tagTable, const char *tagName) { - Ttk_Tag tag = (Ttk_Tag)ckalloc(sizeof(*tag)); + Ttk_Tag tag = ckalloc(sizeof(*tag)); tag->tagRecord = ckalloc(tagTable->recordSize); memset(tag->tagRecord, 0, tagTable->recordSize); /* Don't need Tk_InitOptions() here, all defaults should be NULL. */ @@ -48,7 +48,7 @@ static void DeleteTag(Ttk_TagTable tagTable, Ttk_Tag tag) { Tk_FreeConfigOptions(tag->tagRecord,tagTable->optionTable,tagTable->tkwin); ckfree(tag->tagRecord); - ckfree((void*)tag); + ckfree(tag); } /*------------------------------------------------------------------------ @@ -59,7 +59,7 @@ Ttk_TagTable Ttk_CreateTagTable( Tcl_Interp *interp, Tk_Window tkwin, Tk_OptionSpec optionSpecs[], int recordSize) { - Ttk_TagTable tagTable = (Ttk_TagTable)ckalloc(sizeof(*tagTable)); + Ttk_TagTable tagTable = ckalloc(sizeof(*tagTable)); tagTable->tkwin = tkwin; tagTable->optionSpecs = optionSpecs; tagTable->optionTable = Tk_CreateOptionTable(interp, optionSpecs); @@ -81,7 +81,7 @@ void Ttk_DeleteTagTable(Ttk_TagTable tagTable) } Tcl_DeleteHashTable(&tagTable->tags); - ckfree((void*)tagTable); + ckfree(tagTable); } Ttk_Tag Ttk_GetTag(Ttk_TagTable tagTable, const char *tagName) @@ -117,7 +117,7 @@ Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable tagTable, Tcl_Obj *objPtr) Ttk_TagSet Ttk_GetTagSetFromObj( Tcl_Interp *interp, Ttk_TagTable tagTable, Tcl_Obj *objPtr) { - Ttk_TagSet tagset = (Ttk_TagSet)(ckalloc(sizeof *tagset)); + Ttk_TagSet tagset = ckalloc(sizeof(*tagset)); Tcl_Obj **objv; int i, objc; @@ -128,11 +128,11 @@ Ttk_TagSet Ttk_GetTagSetFromObj( } if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { - ckfree((ClientData)tagset); + ckfree(tagset); return NULL; } - tagset->tags = (Ttk_Tag*)ckalloc((objc+1) * sizeof(Ttk_Tag)); + tagset->tags = ckalloc((objc+1) * sizeof(Ttk_Tag)); for (i=0; i<objc; ++i) { tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]); } @@ -159,8 +159,8 @@ Tcl_Obj *Ttk_NewTagSetObj(Ttk_TagSet tagset) void Ttk_FreeTagSet(Ttk_TagSet tagset) { - ckfree((ClientData)tagset->tags); - ckfree((ClientData)tagset); + ckfree(tagset->tags); + ckfree(tagset); } /* Ttk_TagSetContains -- test if tag set contains a tag. @@ -189,7 +189,7 @@ int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag) return 0; } } - tagset->tags = (void*)ckrealloc((void*)tagset->tags, + tagset->tags = ckrealloc(tagset->tags, (tagset->nTags+1)*sizeof(tagset->tags[0])); tagset->tags[tagset->nTags++] = tag; return 1; diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index e0d1971..2b98eaf 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -42,7 +42,7 @@ typedef struct Ttk_Style_ static Style *NewStyle() { - Style *stylePtr = (Style*)ckalloc(sizeof(Style)); + Style *stylePtr = ckalloc(sizeof(Style)); stylePtr->styleName = NULL; stylePtr->parentStyle = NULL; @@ -77,7 +77,7 @@ static void FreeStyle(Style *stylePtr) Ttk_FreeLayoutTemplate(stylePtr->layoutTemplate); - ckfree((ClientData)stylePtr); + ckfree(stylePtr); } /* @@ -181,7 +181,7 @@ static const Tk_OptionSpec *TTKGetOptionSpec( static OptionMap BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable) { - OptionMap optionMap = (OptionMap)ckalloc( + OptionMap optionMap = ckalloc( sizeof(const Tk_OptionSpec) * elementClass->nResources + 1); int i; @@ -223,8 +223,7 @@ GetOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable) static Ttk_ElementClass * NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData) { - Ttk_ElementClass *elementClass = - (Ttk_ElementClass*)ckalloc(sizeof(Ttk_ElementClass)); + Ttk_ElementClass *elementClass = ckalloc(sizeof(Ttk_ElementClass)); int i; elementClass->name = name; @@ -240,7 +239,7 @@ NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData) /* Initialize default values: */ - elementClass->defaultValues = (Tcl_Obj**) + elementClass->defaultValues = ckalloc(elementClass->nResources * sizeof(Tcl_Obj *) + 1); for (i=0; i < elementClass->nResources; ++i) { const char *defaultValue = specPtr->options[i].defaultValue; @@ -277,7 +276,7 @@ static void FreeElementClass(Ttk_ElementClass *elementClass) Tcl_DecrRefCount(elementClass->defaultValues[i]); } } - ckfree((ClientData)elementClass->defaultValues); + ckfree(elementClass->defaultValues); /* * Free option map cache: @@ -290,7 +289,7 @@ static void FreeElementClass(Ttk_ElementClass *elementClass) Tcl_DeleteHashTable(&elementClass->optMapCache); ckfree(elementClass->elementRecord); - ckfree((ClientData)elementClass); + ckfree(elementClass); } /*------------------------------------------------------------------------ @@ -313,7 +312,7 @@ typedef struct Ttk_Theme_ static Theme *NewTheme(Ttk_ResourceCache cache, Ttk_Theme parent) { - Theme *themePtr = (Theme*)ckalloc(sizeof(Theme)); + Theme *themePtr = ckalloc(sizeof(Theme)); Tcl_HashEntry *entryPtr; int unused; @@ -367,7 +366,7 @@ static void FreeTheme(Theme *themePtr) /* * Free theme record: */ - ckfree((ClientData)themePtr); + ckfree(themePtr); return; } @@ -456,11 +455,11 @@ static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *interp) while (cleanup) { Cleanup *next = cleanup->next; cleanup->cleanupProc(cleanup->clientData); - ckfree((ClientData)cleanup); + ckfree(cleanup); cleanup = next; } - ckfree((ClientData)pkgPtr); + ckfree(pkgPtr); } /* @@ -486,7 +485,7 @@ void Ttk_RegisterCleanup( Tcl_Interp *interp, ClientData clientData, Ttk_CleanupProc *cleanupProc) { StylePackageData *pkgPtr = GetStylePackageData(interp); - Cleanup *cleanup = (Cleanup*)ckalloc(sizeof(*cleanup)); + Cleanup *cleanup = ckalloc(sizeof(*cleanup)); cleanup->clientData = clientData; cleanup->cleanupProc = cleanupProc; @@ -802,7 +801,7 @@ int Ttk_RegisterElementFactory( Ttk_ElementFactory factory, void *clientData) { StylePackageData *pkgPtr = GetStylePackageData(interp); - FactoryRec *recPtr = (FactoryRec*)ckalloc(sizeof(*recPtr)); + FactoryRec *recPtr = ckalloc(sizeof(*recPtr)); Tcl_HashEntry *entryPtr; int newEntry; @@ -1697,8 +1696,7 @@ void Ttk_StylePkgInit(Tcl_Interp *interp) { Tcl_Namespace *nsPtr; - StylePackageData *pkgPtr = (StylePackageData *) - ckalloc(sizeof(StylePackageData)); + StylePackageData *pkgPtr = ckalloc(sizeof(StylePackageData)); pkgPtr->interp = interp; Tcl_InitHashTable(&pkgPtr->themeTable, TCL_STRING_KEYS); diff --git a/generic/ttk/ttkTrace.c b/generic/ttk/ttkTrace.c index cb2f1c7..c8cceaf 100644 --- a/generic/ttk/ttkTrace.c +++ b/generic/ttk/ttkTrace.c @@ -76,7 +76,7 @@ Ttk_TraceHandle *Ttk_TraceVariable( Ttk_TraceProc callback, void *clientData) { - Ttk_TraceHandle *h = (Ttk_TraceHandle*)ckalloc(sizeof(*h)); + Ttk_TraceHandle *h = ckalloc(sizeof(*h)); int status; h->interp = interp; @@ -91,7 +91,7 @@ Ttk_TraceHandle *Ttk_TraceVariable( if (status != TCL_OK) { Tcl_DecrRefCount(h->varnameObj); - ckfree((ClientData)h); + ckfree(h); return NULL; } @@ -109,7 +109,7 @@ void Ttk_UntraceVariable(Ttk_TraceHandle *h) TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, VarTraceProc, (ClientData)h); Tcl_DecrRefCount(h->varnameObj); - ckfree((ClientData)h); + ckfree(h); } } diff --git a/generic/ttk/ttkTrack.c b/generic/ttk/ttkTrack.c index a392d94..74b34e0 100644 --- a/generic/ttk/ttkTrack.c +++ b/generic/ttk/ttkTrack.c @@ -173,7 +173,7 @@ ElementStateEventProc(ClientData clientData, XEvent *ev) void TtkTrackElementState(WidgetCore *corePtr) { - ElementStateTracker *es = (ElementStateTracker*)ckalloc(sizeof(*es)); + ElementStateTracker *es = ckalloc(sizeof(*es)); es->corePtr = corePtr; es->tracking = 0; es->activeElement = es->pressedElement = 0; diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index d7afb3c..b9fe913 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -86,7 +86,7 @@ static Tk_OptionSpec ItemOptionSpecs[] = { */ static TreeItem *NewItem(void) { - TreeItem *item = (TreeItem*)ckalloc(sizeof(*item)); + TreeItem *item = ckalloc(sizeof(*item)); item->entryPtr = 0; item->parent = item->children = item->next = item->prev = NULL; @@ -118,7 +118,7 @@ static void FreeItem(TreeItem *item) if (item->tagset) { Ttk_FreeTagSet(item->tagset); } if (item->imagespec) { TtkFreeImageSpec(item->imagespec); } - ckfree((ClientData)item); + ckfree(item); } static void FreeItemCB(void *clientData) { FreeItem(clientData); } @@ -613,11 +613,11 @@ static TreeItem **GetItemListFromObj( return NULL; } - items = (TreeItem**)ckalloc((nElements + 1)*sizeof(TreeItem*)); + items = ckalloc((nElements + 1)*sizeof(TreeItem*)); for (i = 0; i < nElements; ++i) { items[i] = FindItem(interp, tv, elements[i]); if (!items[i]) { - ckfree((ClientData)items); + ckfree(items); return NULL; } } @@ -659,7 +659,7 @@ static void TreeviewFreeColumns(Treeview *tv) if (tv->tree.columns) { for (i = 0; i < tv->tree.nColumns; ++i) FreeColumn(tv->tree.columns + i); - ckfree((ClientData)tv->tree.columns); + ckfree(tv->tree.columns); tv->tree.columns = 0; } } @@ -688,8 +688,7 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv) * Initialize columns array and columnNames hash table: */ tv->tree.nColumns = ncols; - tv->tree.columns = - (TreeColumn*)ckalloc(tv->tree.nColumns * sizeof(TreeColumn)); + tv->tree.columns = ckalloc(tv->tree.nColumns * sizeof(TreeColumn)); for (i = 0; i < ncols; ++i) { int isNew; @@ -734,16 +733,16 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv) if (!strcmp(Tcl_GetString(tv->tree.displayColumnsObj), "#all")) { ndcols = tv->tree.nColumns; - displayColumns = (TreeColumn**)ckalloc((ndcols+1)*sizeof(TreeColumn*)); + displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*)); for (index = 0; index < ndcols; ++index) { displayColumns[index+1] = tv->tree.columns + index; } } else { - displayColumns = (TreeColumn**)ckalloc((ndcols+1)*sizeof(TreeColumn*)); + displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*)); for (index = 0; index < ndcols; ++index) { displayColumns[index+1] = GetColumn(interp, tv, dcolumns[index]); if (!displayColumns[index+1]) { - ckfree((ClientData)displayColumns); + ckfree(displayColumns); return TCL_ERROR; } } @@ -751,7 +750,7 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv) displayColumns[0] = &tv->tree.column0; if (tv->tree.displayColumns) - ckfree((ClientData)tv->tree.displayColumns); + ckfree(tv->tree.displayColumns); tv->tree.displayColumns = displayColumns; tv->tree.nDisplayColumns = ndcols + 1; @@ -1987,7 +1986,7 @@ static int TreeviewChildrenCommand( */ for (i=0; newChildren[i]; ++i) { if (!AncestryCheck(interp, tv, newChildren[i], item)) { - ckfree((ClientData)newChildren); + ckfree(newChildren); return TCL_ERROR; } } @@ -2023,7 +2022,7 @@ static int TreeviewChildrenCommand( child = newChildren[i]; } - ckfree((ClientData)newChildren); + ckfree(newChildren); TtkRedisplayWidget(&tv->core); } @@ -2649,7 +2648,7 @@ static int TreeviewDetachCommand( for (i = 0; items[i]; ++i) { if (items[i] == tv->tree.root) { Tcl_AppendResult(interp, "Cannot detach root item", NULL); - ckfree((ClientData)items); + ckfree(items); return TCL_ERROR; } } @@ -2659,7 +2658,7 @@ static int TreeviewDetachCommand( } TtkRedisplayWidget(&tv->core); - ckfree((ClientData)items); + ckfree(items); return TCL_OK; } @@ -2695,7 +2694,7 @@ static int TreeviewDeleteCommand( */ for (i=0; items[i]; ++i) { if (items[i] == tv->tree.root) { - ckfree((ClientData)items); + ckfree(items); Tcl_AppendResult(interp, "Cannot delete root item", NULL); return TCL_ERROR; } @@ -2720,7 +2719,7 @@ static int TreeviewDeleteCommand( delq = next; } - ckfree((ClientData)items); + ckfree(items); TtkRedisplayWidget(&tv->core); return TCL_OK; } @@ -2989,7 +2988,7 @@ static int TreeviewSelectionCommand( break; } - ckfree((ClientData)items); + ckfree(items); TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect"); TtkRedisplayWidget(&tv->core); diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index 70900a9..ce16da4 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -99,8 +99,8 @@ TkpDefineNativeBitmaps(void) name = Tk_GetUid(builtInPtr->name); predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); if (isNew) { - TkPredefBitmap *predefPtr = (TkPredefBitmap *) - ckalloc(sizeof(TkPredefBitmap)); + TkPredefBitmap *predefPtr = ckalloc(sizeof(TkPredefBitmap)); + predefPtr->source = UINT2PTR(builtInPtr->iconType); predefPtr->width = builtInIconSize; predefPtr->height = builtInIconSize; @@ -438,7 +438,7 @@ TkMacOSXIconBitmapObjCmd( iconBitmap = Tcl_GetHashValue(hPtr); ckfree(iconBitmap->value); } else { - iconBitmap = (IconBitmap *) ckalloc(sizeof(IconBitmap)); + iconBitmap = ckalloc(sizeof(IconBitmap)); Tcl_SetHashValue(hPtr, iconBitmap); } *iconBitmap = ib; diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 41edd9b..a033990 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -106,7 +106,7 @@ TkButton * TkpCreateButton( Tk_Window tkwin) { - MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); + MacButton *macButtonPtr = ckalloc(sizeof(MacButton)); macButtonPtr->button = nil; macButtonPtr->image = nil; diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index b5a4a87..5906ced 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -595,7 +595,7 @@ TkpGetColor( color.red = color.green = color.blue = rgba[0] * 65535.0; break; default: - Tcl_Panic("CGColor with %d components", n); + Tcl_Panic("CGColor with %d components", (int) n); } color.pixel = ((((((pixelCode << 8) | ((color.red >> 8) & 0xff)) << 8) @@ -609,11 +609,11 @@ TkpGetColor( } if (XParseColor(display, colormap, name, &color) == 0) { - return (TkColor *) NULL; + return NULL; } validXColor: - tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color = color; return tkColPtr; @@ -647,7 +647,7 @@ TkpGetColorByValue( XColor *colorPtr) /* Red, green, and blue fields indicate * desired color. */ { - TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + TkColor *tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index 1312fbd..56ac364 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -383,19 +383,19 @@ TkGetCursorByName( if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) { if (argc) { - macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor)); + macCursorPtr = ckalloc(sizeof(TkMacOSXCursor)); macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr; macCursorPtr->macCursor = nil; macCursorPtr->type = 0; FindCursorByName(macCursorPtr, argv[0]); } - ckfree((char *) argv); + ckfree(argv); } if (!macCursorPtr || (!macCursorPtr->macCursor && macCursorPtr->type != NONE)) { Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); if (macCursorPtr) { - ckfree((char *)macCursorPtr); + ckfree(macCursorPtr); macCursorPtr = NULL; } } diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 8d07996..e1f0fd8 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -162,12 +162,12 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { callbackInfo->cmdObj, &objc, &objv); if (result == TCL_OK && objc) { - 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] = resultObj; TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv, TCL_EVAL_GLOBAL); - ckfree((char *)tmpv); + ckfree(tmpv); } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); @@ -180,7 +180,7 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { } if (callbackInfo->cmdObj) { Tcl_DecrRefCount(callbackInfo->cmdObj); - ckfree((char*) callbackInfo); + ckfree(callbackInfo); } } @@ -200,12 +200,12 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { callbackInfo->cmdObj, &objc, &objv); if (result == TCL_OK && objc) { - 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] = resultObj; TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv, TCL_EVAL_GLOBAL); - ckfree((char *)tmpv); + ckfree(tmpv); } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); @@ -216,7 +216,7 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { } if (callbackInfo->cmdObj) { Tcl_DecrRefCount(callbackInfo->cmdObj); - ckfree((char*) callbackInfo); + ckfree(callbackInfo); } } @end @@ -472,8 +472,7 @@ Tk_GetOpenFileObjCmd( } [panel setAllowsMultipleSelection:multiple]; if (cmdObj) { - callbackInfo = (FilePanelCallbackInfo *) - ckalloc(sizeof(FilePanelCallbackInfo)); + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } @@ -647,8 +646,7 @@ Tk_GetSaveFileObjCmd( [panel setCanSelectHiddenExtension:YES]; [panel setExtensionHidden:NO]; if (cmdObj) { - callbackInfo = (FilePanelCallbackInfo *) - ckalloc(sizeof(FilePanelCallbackInfo)); + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } @@ -769,8 +767,7 @@ Tk_ChooseDirectoryObjCmd( [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:!mustexist]; if (cmdObj) { - callbackInfo = (FilePanelCallbackInfo *) - ckalloc(sizeof(FilePanelCallbackInfo)); + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } @@ -1042,8 +1039,7 @@ Tk_MessageBoxObjCmd( [[buttons objectAtIndex: defaultNativeButtonIndex-1] setKeyEquivalent: @"\r"]; if (cmdObj) { - callbackInfo = (AlertCallbackInfo *) - ckalloc(sizeof(AlertCallbackInfo)); + callbackInfo = ckalloc(sizeof(AlertCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } @@ -1220,13 +1216,12 @@ FontchooserEvent( result = Tcl_ListObjGetElements(fontchooserInterp, fcdPtr->cmdObj, &objc, &objv); if (result == TCL_OK) { - tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * - (unsigned)(objc + 2)); + tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = fontObj; TkBackgroundEvalObjv(fontchooserInterp, objc + 1, tmpv, TCL_EVAL_GLOBAL); - ckfree((char *)tmpv); + ckfree(tmpv); } } TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); @@ -1602,7 +1597,7 @@ DeleteFontchooserData( if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } - ckfree((char *)fcdPtr); + ckfree(fcdPtr); if (fontchooserInterp == interp) { fontchooserInterp = NULL; @@ -1631,8 +1626,7 @@ TkInitFontchooser( Tcl_Interp *interp, ClientData clientData) { - FontchooserData *fcdPtr = (FontchooserData*) - ckalloc(sizeof(FontchooserData)); + FontchooserData *fcdPtr = ckalloc(sizeof(FontchooserData)); bzero(fcdPtr, sizeof(FontchooserData)); Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteFontchooserData, diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index fd1bae6..f29d752 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -92,8 +92,7 @@ Tk_MacOSXSetEmbedHandler( Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) { if (tkMacOSXEmbedHandler == NULL) { - tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *) - ckalloc(sizeof(TkMacOSXEmbedHandler)); + tkMacOSXEmbedHandler = ckalloc(sizeof(TkMacOSXEmbedHandler)); } tkMacOSXEmbedHandler->registerWinProc = registerWinProc; tkMacOSXEmbedHandler->getPortProc = getPortProc; @@ -137,7 +136,7 @@ TkpMakeWindow( * Allocate sub window */ - macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macWin = ckalloc(sizeof(MacDrawable)); if (macWin == NULL) { winPtr->privatePtr = NULL; return None; @@ -263,7 +262,7 @@ TkpUseWindow( * Make the embedded window. */ - macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macWin = ckalloc(sizeof(MacDrawable)); if (macWin == NULL) { winPtr->privatePtr = NULL; return TCL_ERROR; @@ -318,15 +317,15 @@ TkpUseWindow( Tcl_AppendResult(interp, "The window ID ", string, " does not correspond to a valid Tk Window.", NULL); return TCL_ERROR; - } else { - containerPtr = (Container *) ckalloc(sizeof(Container)); - - containerPtr->parentPtr = NULL; - containerPtr->embedded = (Window) macWin; - containerPtr->embeddedPtr = macWin->winPtr; - containerPtr->nextPtr = firstContainerPtr; - firstContainerPtr = containerPtr; } + + containerPtr = ckalloc(sizeof(Container)); + + containerPtr->parentPtr = NULL; + containerPtr->embedded = (Window) macWin; + containerPtr->embeddedPtr = macWin->winPtr; + containerPtr->nextPtr = firstContainerPtr; + firstContainerPtr = containerPtr; } else { /* * The window is embedded in another Tk window. @@ -392,7 +391,7 @@ TkpMakeContainer( */ Tk_MakeWindowExist(tkwin); - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parent = Tk_WindowId(tkwin); containerPtr->parentPtr = winPtr; containerPtr->embedded = None; @@ -1117,7 +1116,7 @@ EmbedWindowDeleted( } else { prevPtr->nextPtr = containerPtr->nextPtr; } - ckfree((char *) containerPtr); + ckfree(containerPtr); } } diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 37d4efe..d8d71d7 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -135,7 +135,7 @@ TkMacOSXFlushWindows(void) NSCountWindows(&windowCount); if(windowCount) { - windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); + windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; @@ -143,7 +143,7 @@ TkMacOSXFlushWindows(void) [w flushWindow]; } } - ckfree((char*) windowNumbers); + ckfree(windowNumbers); } } diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 7548ace..5bd9265 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -453,7 +453,7 @@ TkpGetNativeFont( ctFont = CTFontCreateUIFontForLanguage(HIThemeGetUIFontType( themeFontId), 0, NULL); if (ctFont) { - fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); + fontPtr = ckalloc(sizeof(MacFont)); InitFont((NSFont*) ctFont, NULL, fontPtr); } @@ -522,7 +522,7 @@ TkpGetFontFromAttributes( Tcl_Panic("Could not deternmine NSFont from TkFontAttributes"); } if (tkFontPtr == NULL) { - fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); + fontPtr = ckalloc(sizeof(MacFont)); } else { fontPtr = (MacFont *) tkFontPtr; TkpDeleteFont(tkFontPtr); diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 6157d48..11ac7e6 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -188,7 +188,7 @@ QuitHandler( * quickly as possible. */ - eventPtr = (KillEvent *) ckalloc(sizeof(KillEvent)); + eventPtr = ckalloc(sizeof(KillEvent)); eventPtr->header.proc = ReallyKillMe; eventPtr->interp = interp; diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index a12273e..bd9d008 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -460,7 +460,7 @@ XGetModifierMapping( * don't generate them either. So there is no modifier map. */ - modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap)); + modmap = ckalloc(sizeof(XModifierKeymap)); modmap->max_keypermod = 0; modmap->modifiermap = NULL; return modmap; @@ -487,9 +487,9 @@ XFreeModifiermap( XModifierKeymap *modmap) { if (modmap->modifiermap != NULL) { - ckfree((char *) modmap->modifiermap); + ckfree(modmap->modifiermap); } - ckfree((char *) modmap); + ckfree(modmap); } /* @@ -899,7 +899,7 @@ TkpInitKeymapInfo( */ if (dispPtr->modKeyCodes != NULL) { - ckfree((char *) dispPtr->modKeyCodes); + ckfree(dispPtr->modKeyCodes); } dispPtr->numModKeyCodes = 0; dispPtr->modKeyCodes = NULL; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 42064ae..dcb4a3f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1424,10 +1424,10 @@ TkpMenuInit(void) [NSMenuItem setUsesUserKeyEquivalents:NO]; tkColPtr = TkpGetColor(None, DEF_MENU_BG_COLOR); defaultBg = tkColPtr->color.pixel; - ckfree((char *) tkColPtr); + ckfree(tkColPtr); tkColPtr = TkpGetColor(None, DEF_MENU_FG); defaultFg = tkColPtr->color.pixel; - ckfree((char *) tkColPtr); + ckfree(tkColPtr); ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth, &menuMarkColumnWidth); diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 4b0e0be..dafbb25 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -89,11 +89,9 @@ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { - MacMenuButton *macButtonPtr = - (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); + MacMenuButton *macButtonPtr = ckalloc(sizeof(MacMenuButton)); macButtonPtr->button = nil; - Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, (ClientData) macButtonPtr); return (TkMenuButton *) macButtonPtr; diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 02a6832..9a4c03e 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -78,7 +78,7 @@ TkScale * TkpCreateScale( Tk_Window tkwin) { - MacScale *macScalePtr = (MacScale *) ckalloc(sizeof(MacScale)); + MacScale *macScalePtr = ckalloc(sizeof(MacScale)); macScalePtr->scaleHandle = NULL; if (scaleActionProc == NULL) { diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index aabc719..0d18695 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -227,7 +227,7 @@ TkScrollbar * TkpCreateScrollbar( Tk_Window tkwin) { - MacScrollbar *scrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar)); + MacScrollbar *scrollPtr = ckalloc(sizeof(MacScrollbar)); scrollPtr->scroller = nil; Tk_CreateEventHandler(tkwin, StructureNotifyMask|FocusChangeMask| diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index 3ba434a..4734faf 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -283,7 +283,7 @@ Tk_SetAppName( * We have found a unique name. Now add it to the registry. */ - riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp)); + riPtr = ckalloc(sizeof(RegisteredInterp)); riPtr->interp = interp; riPtr->name = ckalloc(strlen(actualName) + 1); riPtr->nextPtr = interpListPtr; diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 0f13aae..4107450 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -83,9 +83,9 @@ XDestroyWindow( } if (macWin->toplevel->referenceCount == 0) { - ckfree((char *) macWin->toplevel); + ckfree(macWin->toplevel); } - ckfree((char *) macWin); + ckfree(macWin); return; } if (macWin->visRgn) { @@ -105,7 +105,7 @@ XDestroyWindow( */ if (macWin->toplevel->referenceCount == 0) { - ckfree((char *) macWin->toplevel); + ckfree(macWin->toplevel); } } @@ -1290,7 +1290,7 @@ Tk_GetPixmap( if (display != NULL) { display->request++; } - macPix = (MacDrawable *) ckalloc(sizeof(MacDrawable)); + macPix = ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; @@ -1339,7 +1339,7 @@ Tk_FreePixmap( } CFRelease(macPix->context); } - ckfree((char *) macPix); + ckfree(macPix); } /* diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index fa1839f..4df82fe 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -468,7 +468,7 @@ FrontWindowAtPoint( NSCountWindows(&windowCount); if (windowCount) { - windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); + windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; @@ -477,7 +477,7 @@ FrontWindowAtPoint( break; } } - ckfree((char *) windowNumbers); + ckfree(windowNumbers); } return (win ? TkMacOSXGetTkWindow(win) : NULL); } @@ -504,7 +504,7 @@ void TkWmNewWindow( TkWindow *winPtr) /* Newly-created top-level window. */ { - WmInfo *wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo)); + WmInfo *wmPtr = ckalloc(sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; @@ -761,10 +761,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) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); @@ -788,7 +788,7 @@ TkWmDeadWindow( TkMacOSXMakeCollectableAndRelease(wmPtr->window); } - ckfree((char *) wmPtr); + ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } @@ -1351,15 +1351,15 @@ WmClientCmd( argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); wmPtr->clientMachine = NULL; } return TCL_OK; } if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc((unsigned) length + 1); + wmPtr->clientMachine = ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } @@ -1414,12 +1414,11 @@ WmColormapwindowsCmd( != TCL_OK) { return TCL_ERROR; } - cmapList = (TkWindow **) ckalloc((unsigned) - ((windowObjc+1) * sizeof(TkWindow*))); + cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { - ckfree((char *) cmapList); + ckfree(cmapList); return TCL_ERROR; } if (winPtr2 == winPtr) { @@ -1439,7 +1438,7 @@ WmColormapwindowsCmd( } wmPtr->flags |= WM_COLORMAPS_EXPLICIT; if (wmPtr->cmapList != NULL) { - ckfree((char *) wmPtr->cmapList); + ckfree(wmPtr->cmapList); } wmPtr->cmapList = cmapList; wmPtr->cmapCount = windowObjc; @@ -1497,7 +1496,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; } return TCL_OK; @@ -1506,7 +1505,7 @@ WmCommandCmd( return TCL_ERROR; } if (wmPtr->cmdArgv != NULL) { - ckfree((char *) wmPtr->cmdArgv); + ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; @@ -1927,7 +1926,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc((unsigned) (length + 1)); + wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; @@ -2153,10 +2152,10 @@ WmIconnameCmd( } 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); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); @@ -2731,7 +2730,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; @@ -2928,7 +2927,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; @@ -2983,7 +2982,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) { @@ -3231,7 +3230,7 @@ WmTransientCmd( if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } - wmPtr->masterWindowName = ckalloc((unsigned) length+1); + wmPtr->masterWindowName = ckalloc(length+1); strcpy(wmPtr->masterWindowName, masterWindowName); } ApplyMasterOverrideChanges(winPtr, NULL); @@ -4542,7 +4541,7 @@ TkWmAddToColormapWindows( * 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 *)); } @@ -4552,7 +4551,7 @@ TkWmAddToColormapWindows( newPtr[count-1] = winPtr; newPtr[count] = topPtr; if (oldPtr != NULL) { - ckfree((char *) oldPtr); + ckfree(oldPtr); } topPtr->wmInfoPtr->cmapList = newPtr; @@ -5945,8 +5944,7 @@ TkWmStackorderToplevel( Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(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 @@ -5966,12 +5964,12 @@ TkWmStackorderToplevel( NSCountWindows(&windowCount); if (!windowCount) { - ckfree((char *) windows); + ckfree(windows); windows = NULL; } else { window_ptr = windows + table.numEntries; *window_ptr-- = NULL; - windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); + windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; @@ -5988,7 +5986,7 @@ TkWmStackorderToplevel( Tcl_Panic("num matched toplevel windows does not equal num " "children"); } - ckfree((char *) windowNumbers); + ckfree(windowNumbers); } done: diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 8bef50d..70f8e39 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -153,8 +153,8 @@ TkpOpenDisplay( } } - display = (Display *) ckalloc(sizeof(Display)); - screen = (Screen *) ckalloc(sizeof(Screen)); + display = ckalloc(sizeof(Display)); + screen = ckalloc(sizeof(Screen)); bzero(display, sizeof(Display)); bzero(screen, sizeof(Screen)); @@ -194,7 +194,7 @@ TkpOpenDisplay( screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24; screen->ext_data = (XExtData *) &maxBounds; - screen->root_visual = (Visual *) ckalloc(sizeof(Visual)); + screen->root_visual = ckalloc(sizeof(Visual)); screen->root_visual->visualid = 0; screen->root_visual->class = TrueColor; screen->root_visual->red_mask = 0x00FF0000; @@ -209,7 +209,7 @@ TkpOpenDisplay( TkMacOSXDisplayChanged(display); - gMacDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay)); + gMacDisplay = ckalloc(sizeof(TkDisplay)); /* * This is the quickest way to make sure that all the *Init flags get @@ -251,11 +251,11 @@ TkpCloseDisplay( gMacDisplay = NULL; if (display->screens != NULL) { if (display->screens->root_visual != NULL) { - ckfree((char *) display->screens->root_visual); + ckfree(display->screens->root_visual); } - ckfree((char *) display->screens); + ckfree(display->screens); } - ckfree((char *) display); + ckfree(display); } /* @@ -784,7 +784,7 @@ XCreateImage( XImage *ximage; display->request++; - ximage = (XImage *) ckalloc(sizeof(XImage)); + ximage = ckalloc(sizeof(XImage)); ximage->height = height; ximage->width = width; @@ -946,7 +946,7 @@ DestroyImage( } else if (image->data) { ckfree(image->data); } - ckfree((char*) image); + ckfree(image); } return 0; } diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index b4efbf8..f9be640 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -48,7 +48,8 @@ typedef struct { TkBorder * TkpGetBorder(void) { - UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder)); + UnixBorder *borderPtr = ckalloc(sizeof(UnixBorder)); + borderPtr->solidGC = None; return (TkBorder *) borderPtr; } diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index c4c9c44..de6cf2a 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -330,7 +330,8 @@ TkButton * TkpCreateButton( Tk_Window tkwin) { - UnixButton *butPtr = (UnixButton *) ckalloc(sizeof(UnixButton)); + UnixButton *butPtr = ckalloc(sizeof(UnixButton)); + return (TkButton *) butPtr; } diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c index 4e872ed..38434e9 100644 --- a/unix/tkUnixColor.c +++ b/unix/tkUnixColor.c @@ -178,7 +178,7 @@ TkpGetColor( } } - tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color = color; return tkColPtr; @@ -213,7 +213,7 @@ TkpGetColorByValue( { Display *display = Tk_Display(tkwin); Colormap colormap = Tk_Colormap(tkwin); - TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + TkColor *tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; @@ -271,7 +271,7 @@ FindClosestColor( for (stressPtr = dispPtr->stressPtr; ; stressPtr = stressPtr->nextPtr) { if (stressPtr == NULL) { - stressPtr = (TkStressedCmap *) ckalloc(sizeof(TkStressedCmap)); + stressPtr = ckalloc(sizeof(TkStressedCmap)); stressPtr->colormap = colormap; template.visualid = XVisualIDFromVisual(Tk_Visual(tkwin)); @@ -283,8 +283,8 @@ FindClosestColor( stressPtr->numColors = visInfoPtr->colormap_size; XFree((char *) visInfoPtr); - stressPtr->colorPtr = (XColor *) ckalloc((unsigned) - (stressPtr->numColors * sizeof(XColor))); + stressPtr->colorPtr = + ckalloc(stressPtr->numColors * sizeof(XColor)); for (i = 0; i < stressPtr->numColors; i++) { stressPtr->colorPtr[i].pixel = (unsigned long) i; } @@ -392,8 +392,8 @@ DeleteStressedCmap( } else { prevPtr->nextPtr = stressPtr->nextPtr; } - ckfree((char *) stressPtr->colorPtr); - ckfree((char *) stressPtr); + ckfree(stressPtr->colorPtr); + ckfree(stressPtr); return; } } diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c index 59c415a..fbb4148 100644 --- a/unix/tkUnixCursor.c +++ b/unix/tkUnixCursor.c @@ -334,20 +334,20 @@ TkGetCursorByName( } if (cursor != None) { - cursorPtr = (TkUnixCursor *) ckalloc(sizeof(TkUnixCursor)); + cursorPtr = ckalloc(sizeof(TkUnixCursor)); cursorPtr->info.cursor = (Tk_Cursor) cursor; cursorPtr->display = display; } cleanup: if (argv != NULL) { - ckfree((char *) argv); + ckfree(argv); } return (TkCursor *) cursorPtr; badString: if (argv) { - ckfree((char *) argv); + ckfree(argv); } Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); return NULL; @@ -594,7 +594,7 @@ TkCreateCursorFromData( Tk_FreePixmap(display, maskPixmap); if (cursor != None) { - cursorPtr = (TkUnixCursor *) ckalloc(sizeof(TkUnixCursor)); + cursorPtr = ckalloc(sizeof(TkUnixCursor)); cursorPtr->info.cursor = (Tk_Cursor) cursor; cursorPtr->display = display; } diff --git a/unix/tkUnixDialog.c b/unix/tkUnixDialog.c index 851edf3..7cddcbd 100644 --- a/unix/tkUnixDialog.c +++ b/unix/tkUnixDialog.c @@ -49,14 +49,14 @@ EvalObjv( cmdObj = Tcl_NewStringObj(cmdName, -1); Tcl_IncrRefCount(cmdObj); - objs = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj*) * (unsigned)(objc+1)); + objs = ckalloc(sizeof(Tcl_Obj *) * (objc+1)); objs[0] = cmdObj; memcpy(objs+1, objv, sizeof(Tcl_Obj *) * (unsigned)objc); result = Tcl_EvalObjv(interp, objc+1, objs, 0); Tcl_DecrRefCount(cmdObj); - ckfree((char *) objs); + ckfree(objs); return result; } diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index 206beb2..cd09974 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -179,7 +179,7 @@ TkpUseWindow( } } if (containerPtr == NULL) { - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parent = parent; containerPtr->parentRoot = parentAtts.root; containerPtr->parentPtr = NULL; @@ -282,7 +282,7 @@ TkpMakeContainer( */ Tk_MakeWindowExist(tkwin); - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parent = Tk_WindowId(tkwin); containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin)); containerPtr->parentPtr = winPtr; @@ -975,7 +975,7 @@ EmbedWindowDeleted( } else { prevPtr->nextPtr = containerPtr->nextPtr; } - ckfree((char *) containerPtr); + ckfree(containerPtr); } } diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 390c72a..5c13762 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -123,7 +123,7 @@ TkpOpenDisplay( if (display == NULL) { return NULL; } - dispPtr = (TkDisplay *) ckalloc(sizeof(TkDisplay)); + dispPtr = ckalloc(sizeof(TkDisplay)); memset(dispPtr, 0, sizeof(TkDisplay)); dispPtr->display = display; #ifdef TK_USE_INPUT_METHODS diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 62f594b..c168622 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -721,7 +721,7 @@ TkpGetNativeFont( } fontStructPtr = CreateClosestFont(tkwin, &fa.fa, &fa.xa); } - fontPtr = (UnixFont *) ckalloc(sizeof(UnixFont)); + fontPtr = ckalloc(sizeof(UnixFont)); InitFont(tkwin, fontStructPtr, fontPtr); return (TkFont *) fontPtr; @@ -777,7 +777,7 @@ TkpGetFontFromAttributes( fontPtr = (UnixFont *) tkFontPtr; if (fontPtr == NULL) { - fontPtr = (UnixFont *) ckalloc(sizeof(UnixFont)); + fontPtr = ckalloc(sizeof(UnixFont)); } else { ReleaseFont(fontPtr); } @@ -1729,7 +1729,7 @@ ReleaseFont( ReleaseSubFont(fontPtr->display, &fontPtr->subFontArray[i]); } if (fontPtr->subFontArray != fontPtr->staticSubFonts) { - ckfree((char *) fontPtr->subFontArray); + ckfree(fontPtr->subFontArray); } } @@ -1846,7 +1846,7 @@ AllocFontFamily( } } - familyPtr = (FontFamily *) ckalloc(sizeof(FontFamily)); + familyPtr = ckalloc(sizeof(FontFamily)); memset(familyPtr, 0, sizeof(FontFamily)); familyPtr->nextPtr = tsdPtr->fontFamilyList; tsdPtr->fontFamilyList = familyPtr; @@ -1933,7 +1933,7 @@ FreeFontFamily( familyPtrPtr = &(*familyPtrPtr)->nextPtr; } - ckfree((char *) familyPtr); + ckfree(familyPtr); } /* @@ -2213,7 +2213,7 @@ FontMapLoadPage( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - subFontPtr->fontMap[row] = (char *) ckalloc(FONTMAP_BITSPERPAGE / 8); + subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8); memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8); if (subFontPtr->familyPtr == &tsdPtr->controlFamily) { @@ -2545,7 +2545,7 @@ CanUseFallback( * make a copy. */ - nameList = (char **) ckalloc(numNames * sizeof(char *)); + nameList = ckalloc(numNames * sizeof(char *)); memcpy(nameList, nameListOrig, numNames * sizeof(char *)); } nameList[nameIdx] = NULL; @@ -2563,7 +2563,7 @@ CanUseFallback( if (fontStructPtr == NULL) { if (nameList != nameListOrig) { - ckfree((char *) nameList); + ckfree(nameList); } XFreeFontNames(nameListOrig); return NULL; @@ -2583,16 +2583,15 @@ CanUseFallback( goto retry; } if (nameList != nameListOrig) { - ckfree((char *) nameList); + ckfree(nameList); } XFreeFontNames(nameListOrig); if (fontPtr->numSubFonts >= SUBFONT_SPACE) { SubFont *newPtr; - newPtr = (SubFont *) - ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1)); - memcpy((char *) newPtr, fontPtr->subFontArray, + newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1)); + memcpy(newPtr, fontPtr->subFontArray, fontPtr->numSubFonts * sizeof(SubFont)); if (fixSubFontPtrPtr != NULL) { register SubFont *fixSubFontPtr = *fixSubFontPtrPtr; @@ -2603,7 +2602,7 @@ CanUseFallback( } } if (fontPtr->subFontArray != fontPtr->staticSubFonts) { - ckfree((char *) fontPtr->subFontArray); + ckfree(fontPtr->subFontArray); } fontPtr->subFontArray = newPtr; } diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 47646b5..a1afffa 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -204,7 +204,7 @@ TkpGetString( * from having to reenter the XIM engine. [Bug 1373712] */ - kePtr->charValuePtr = ckalloc((unsigned) len + 1); + kePtr->charValuePtr = ckalloc(len + 1); kePtr->charValueLen = len; memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), (unsigned) len + 1); return Tcl_DStringValue(dsPtr); @@ -417,12 +417,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; @@ -449,11 +448,10 @@ TkpInitKeymapInfo( */ arraySize *= 2; - newCodes = (KeyCode *) - ckalloc((unsigned) (arraySize * sizeof(KeyCode))); + newCodes = ckalloc(arraySize * sizeof(KeyCode)); memcpy(newCodes, dispPtr->modKeyCodes, dispPtr->numModKeyCodes * sizeof(KeyCode)); - ckfree((char *) dispPtr->modKeyCodes); + ckfree(dispPtr->modKeyCodes); dispPtr->modKeyCodes = newCodes; } dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr; diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index 790d804..04769fd 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -36,7 +36,7 @@ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { - return (TkMenuButton *)ckalloc(sizeof(TkMenuButton)); + return ckalloc(sizeof(TkMenuButton)); } /* diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index d77ee5f..ba19303 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -240,7 +240,7 @@ InitFont( int i, iWidth; if (!fontPtr) { - fontPtr = (UnixFtFont *) ckalloc(sizeof(UnixFtFont)); + fontPtr = ckalloc(sizeof(UnixFtFont)); } FcConfigSubstitute(0, pattern, FcMatchPattern); @@ -252,13 +252,13 @@ InitFont( set = FcFontSort(0, pattern, FcTrue, NULL, &result); if (!set) { - ckfree((char *) fontPtr); + ckfree(fontPtr); return NULL; } fontPtr->fontset = set; fontPtr->pattern = pattern; - fontPtr->faces = (UnixFtFace *) ckalloc(set->nfont * sizeof(UnixFtFace)); + fontPtr->faces = ckalloc(set->nfont * sizeof(UnixFtFace)); fontPtr->nfaces = set->nfont; /* @@ -357,7 +357,7 @@ FinishedWithFont( } } if (fontPtr->faces) { - ckfree((char *) fontPtr->faces); + ckfree(fontPtr->faces); } if (fontPtr->pattern) { FcPatternDestroy(fontPtr->pattern); diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index 7e06b3f..102e03f 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -48,7 +48,7 @@ TkScale * TkpCreateScale( Tk_Window tkwin) { - return (TkScale *) ckalloc(sizeof(TkScale)); + return ckalloc(sizeof(TkScale)); } /* diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 2af22b8..122c906 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -65,8 +65,7 @@ TkScrollbar * TkpCreateScrollbar( Tk_Window tkwin) { - UnixScrollbar *scrollPtr = (UnixScrollbar *) - ckalloc(sizeof(UnixScrollbar)); + UnixScrollbar *scrollPtr = ckalloc(sizeof(UnixScrollbar)); scrollPtr->troughGC = None; scrollPtr->copyGC = None; diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index 6e39ee4..6dd5008 100644 --- a/unix/tkUnixSelect.c +++ b/unix/tkUnixSelect.c @@ -644,14 +644,14 @@ TkSelEventProc( } if (propInfo[numItems] != '\0') { - propData = ckalloc((size_t) numItems + 1); + propData = ckalloc(numItems + 1); strcpy(propData, propInfo); propData[numItems] = '\0'; } retrPtr->result = retrPtr->proc(retrPtr->clientData, retrPtr->interp, propData); if (propData != propInfo) { - ckfree((char *) propData); + ckfree(propData); } } else if (type == dispPtr->incrAtom) { @@ -886,8 +886,7 @@ ConvertSelection( * below). */ - incr.converts = (ConvertInfo *) - ckalloc((unsigned) incr.numConversions * sizeof(ConvertInfo)); + incr.converts = ckalloc(incr.numConversions * sizeof(ConvertInfo)); incr.numIncrs = 0; for (i = 0; i < incr.numConversions; i++) { Atom target, property, type; @@ -1075,7 +1074,7 @@ ConvertSelection( * All done. Cleanup and return. */ - ckfree((char *) incr.converts); + ckfree(incr.converts); if (multiple) { XFree((char *) incr.multAtoms); } @@ -1426,7 +1425,7 @@ SelCvtToX( if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) { return NULL; } - propPtr = (long *) ckalloc((unsigned) numFields*sizeof(long)); + propPtr = ckalloc(numFields * sizeof(long)); /* * Convert the fields one-by-one. @@ -1451,7 +1450,7 @@ SelCvtToX( * Release the parsed list. */ - ckfree((char *) field); + ckfree(field); *numLongsPtr = i; return propPtr; } diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c index 515be11..36069e0 100644 --- a/unix/tkUnixSend.c +++ b/unix/tkUnixSend.c @@ -268,7 +268,7 @@ RegOpen( SendInit(interp, dispPtr); } - regPtr = (NameRegistry *) ckalloc(sizeof(NameRegistry)); + regPtr = ckalloc(sizeof(NameRegistry)); regPtr->dispPtr = dispPtr; regPtr->locked = 0; regPtr->modified = 0; @@ -475,7 +475,7 @@ RegAddName( sprintf(id, "%x ", (unsigned) commWindow); idLength = strlen(id); newBytes = idLength + strlen(name) + 1; - newProp = ckalloc((unsigned) (regPtr->propLength + newBytes)); + newProp = ckalloc(regPtr->propLength + newBytes); strcpy(newProp, id); strcpy(newProp+idLength, name); if (regPtr->property != NULL) { @@ -549,7 +549,7 @@ RegClose( ckfree(regPtr->property); } } - ckfree((char *) regPtr); + ckfree(regPtr); } /* @@ -635,7 +635,7 @@ ValidateName( break; } } - ckfree((char *) argv); + ckfree(argv); } } else { result = 0; @@ -819,7 +819,7 @@ Tk_SetAppName( * the "send" command to the interpreter. */ - riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp)); + riPtr = ckalloc(sizeof(RegisteredInterp)); riPtr->interp = interp; riPtr->dispPtr = winPtr->dispPtr; riPtr->nextPtr = tsdPtr->interpListPtr; @@ -903,7 +903,7 @@ Tk_SetAppName( RegAddName(regPtr, actualName, Tk_WindowId(dispPtr->commTkwin)); RegClose(regPtr); - riPtr->name = (char *) ckalloc((unsigned) (strlen(actualName) + 1)); + riPtr->name = ckalloc(strlen(actualName) + 1); strcpy(riPtr->name, actualName); if (actualName != name) { Tcl_DStringFree(&dString); @@ -1159,7 +1159,7 @@ Tk_SendCmd( msg = "target application died"; } pending.code = TCL_ERROR; - pending.result = (char *) ckalloc((unsigned) (strlen(msg) + 1)); + pending.result = ckalloc(strlen(msg) + 1); strcpy(pending.result, msg); pending.gotResponse = 1; } else { @@ -1681,19 +1681,16 @@ SendEventProc( } pcPtr->code = code; if (resultString != NULL) { - pcPtr->result = - ckalloc((unsigned) (strlen(resultString) + 1)); + pcPtr->result = ckalloc(strlen(resultString) + 1); strcpy(pcPtr->result, resultString); } if (code == TCL_ERROR) { if (errorInfo != NULL) { - pcPtr->errorInfo = - ckalloc((unsigned) (strlen(errorInfo) + 1)); + pcPtr->errorInfo = ckalloc(strlen(errorInfo) + 1); strcpy(pcPtr->errorInfo, errorInfo); } if (errorCode != NULL) { - pcPtr->errorCode = - ckalloc((unsigned) (strlen(errorCode) + 1)); + pcPtr->errorCode = ckalloc(strlen(errorCode) + 1); strcpy(pcPtr->errorCode, errorCode); } } @@ -1782,8 +1779,7 @@ AppendErrorProc( for (pcPtr = tsdPtr->pendingCommands; pcPtr != NULL; pcPtr = pcPtr->nextPtr) { if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) { - pcPtr->result = (char *) ckalloc((unsigned) - (strlen(pcPtr->target) + 50)); + pcPtr->result = ckalloc(strlen(pcPtr->target) + 50); sprintf(pcPtr->result, "no application named \"%s\"", pcPtr->target); pcPtr->code = TCL_ERROR; @@ -1837,7 +1833,7 @@ DeleteProc( } } } - ckfree((char *) riPtr->name); + ckfree(riPtr->name); riPtr->interp = NULL; UpdateCommWindow(riPtr->dispPtr); Tcl_EventuallyFree(riPtr, TCL_DYNAMIC); diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 61b94a7..4143efa 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -497,7 +497,7 @@ void TkWmCleanup( ckfree(wmPtr->iconName); } if (wmPtr->iconDataPtr != NULL) { - ckfree((char *) wmPtr->iconDataPtr); + ckfree(wmPtr->iconDataPtr); } if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); @@ -515,15 +515,15 @@ void TkWmCleanup( 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); } - ckfree((char *) wmPtr); + ckfree(wmPtr); } if (dispPtr->iconDataPtr != NULL) { - ckfree((char *) dispPtr->iconDataPtr); + ckfree(dispPtr->iconDataPtr); dispPtr->iconDataPtr = NULL; } } @@ -552,7 +552,7 @@ TkWmNewWindow( register WmInfo *wmPtr; TkDisplay *dispPtr = winPtr->dispPtr; - wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo)); + wmPtr = ckalloc(sizeof(WmInfo)); memset(wmPtr, 0, sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; @@ -842,7 +842,7 @@ TkWmDeadWindow( ckfree(wmPtr->iconName); } if (wmPtr->iconDataPtr != NULL) { - ckfree((char *) wmPtr->iconDataPtr); + ckfree(wmPtr->iconDataPtr); } if (wmPtr->hints.flags & IconPixmapHint) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); @@ -887,10 +887,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); @@ -935,7 +935,7 @@ TkWmDeadWindow( StructureNotifyMask, WmWaitMapProc, winPtr); wmPtr->masterPtr = NULL; } - ckfree((char *) wmPtr); + ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } @@ -1459,7 +1459,7 @@ WmClientCmd( argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); wmPtr->clientMachine = NULL; if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window, @@ -1470,9 +1470,9 @@ WmClientCmd( return TCL_OK; } if (wmPtr->clientMachine != NULL) { - ckfree((char *) wmPtr->clientMachine); + ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc((unsigned) length + 1); + wmPtr->clientMachine = ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XTextProperty textProp; @@ -1569,14 +1569,14 @@ WmColormapwindowsCmd( != TCL_OK) { return TCL_ERROR; } - cmapList = (Window *) ckalloc((unsigned) (windowObjc+1) * sizeof(Window)); + cmapList = ckalloc((windowObjc+1) * sizeof(Window)); gotToplevel = 0; for (i = 0; i < windowObjc; i++) { Tk_Window mapWin; if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], &mapWin) != TCL_OK) { - ckfree((char *) cmapList); + ckfree(cmapList); return TCL_ERROR; } winPtr2 = (TkWindow *) mapWin; @@ -1598,7 +1598,7 @@ WmColormapwindowsCmd( wmPtr->flags |= WM_COLORMAPS_EXPLICIT; XSetWMColormapWindows(winPtr->display, wmPtr->wrapperPtr->window, cmapList, windowObjc); - ckfree((char *) cmapList); + ckfree(cmapList); return TCL_OK; } @@ -1647,7 +1647,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, wmPtr->wrapperPtr->window, @@ -1660,7 +1660,7 @@ WmCommandCmd( return TCL_ERROR; } if (wmPtr->cmdArgv != NULL) { - ckfree((char *) wmPtr->cmdArgv); + ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; @@ -2083,7 +2083,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc((unsigned) length + 1); + wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } UpdateHints(winPtr); @@ -2310,10 +2310,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); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { UpdateTitle(winPtr); @@ -2396,8 +2396,7 @@ WmIconphotoCmd( * defines CARD32 arrays to use. [Bug 2902814] */ - iconPropertyData = (unsigned long *) - attemptckalloc(sizeof(unsigned long) * size); + iconPropertyData = attemptckalloc(sizeof(unsigned long) * size); if (iconPropertyData == NULL) { return TCL_ERROR; } @@ -2448,12 +2447,12 @@ WmIconphotoCmd( } } if (wmPtr->iconDataPtr != NULL) { - ckfree((char *) wmPtr->iconDataPtr); + ckfree(wmPtr->iconDataPtr); wmPtr->iconDataPtr = NULL; } if (isDefault) { if (winPtr->dispPtr->iconDataPtr != NULL) { - ckfree((char *) winPtr->dispPtr->iconDataPtr); + ckfree(winPtr->dispPtr->iconDataPtr); } winPtr->dispPtr->iconDataPtr = (unsigned char *) iconPropertyData; winPtr->dispPtr->iconDataSize = size; @@ -3023,7 +3022,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; @@ -3205,7 +3204,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 { @@ -3257,7 +3256,7 @@ WmStackorderCmd( } } /* ASSERT: index1 != -1 && index2 != -2 [Bug 1789819] */ - ckfree((char *) windows); + ckfree(windows); if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { @@ -3408,10 +3407,10 @@ WmTitleCmd( return TCL_OK; } else { if (wmPtr->title != NULL) { - ckfree((char *) wmPtr->title); + ckfree(wmPtr->title); } argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->title = ckalloc((unsigned) length + 1); + wmPtr->title = ckalloc(length + 1); strcpy(wmPtr->title, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { @@ -5381,13 +5380,14 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr) } if (objc > 0) { - atoms = (Atom *)ckalloc(sizeof(Atom) * objc); + atoms = ckalloc(sizeof(Atom) * objc); } for (n = 0; n < objc; ++n) { Tcl_DString ds, dsName; int len; char *name = Tcl_GetStringFromObj(objv[n], &len); + Tcl_UtfToUpper(name); Tcl_UtfToExternalDString(NULL, name, len, &dsName); Tcl_DStringInit(&ds); @@ -5409,7 +5409,7 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr) XChangeProperty(Tk_Display(tkwin), wrapperPtr->window, typeAtom, XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, objc); - ckfree((char *)atoms); + ckfree(atoms); return TCL_OK; } @@ -6127,7 +6127,7 @@ UpdateWmProtocols( protPtr = protPtr->nextPtr, count++) { /* Empty loop body; we're just counting the handlers. */ } - arrayPtr = (Atom *) ckalloc((unsigned) count * sizeof(Atom)); + arrayPtr = ckalloc(count * sizeof(Atom)); deleteWindowAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, "WM_DELETE_WINDOW"); pingAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, "_NET_WM_PING"); @@ -6144,7 +6144,7 @@ UpdateWmProtocols( Tk_InternAtom((Tk_Window) wmPtr->winPtr, "WM_PROTOCOLS"), XA_ATOM, 32, PropModeReplace, (unsigned char *) arrayPtr, atomPtr-arrayPtr); - ckfree((char *) arrayPtr); + ckfree(arrayPtr); } /* @@ -6320,8 +6320,7 @@ TkWmStackorderToplevel( Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); - window_ptr = windows = (TkWindow **) - ckalloc((table.numEntries+1) * sizeof(TkWindow *)); + window_ptr = windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); /* * Special cases: If zero or one toplevels were mapped there is no need to @@ -6346,7 +6345,7 @@ TkWmStackorderToplevel( if (XQueryTree(parentPtr->display, vRoot, &dummy1, &dummy2, &children, &numChildren) == 0) { - ckfree((char *) windows); + ckfree(windows); windows = NULL; } else { for (i = 0; i < numChildren; i++) { @@ -6522,7 +6521,7 @@ TkWmAddToColormapWindows( * add the toplevel itself as the last element of the list. */ - newPtr = (Window *) ckalloc((unsigned) (count+2) * sizeof(Window)); + newPtr = ckalloc((count+2) * sizeof(Window)); for (i = 0; i < count; i++) { newPtr[i] = oldPtr[i]; } @@ -6533,7 +6532,7 @@ TkWmAddToColormapWindows( newPtr[count] = topPtr->window; XSetWMColormapWindows(topPtr->display, wrapperPtr->window, newPtr, count+1); - ckfree((char *) newPtr); + ckfree(newPtr); if (oldPtr != NULL) { XFree((char *) oldPtr); } @@ -7213,8 +7212,8 @@ UpdateCommand( * entire DString is done. */ - cmdArgv = (char **) ckalloc(sizeof(char *) * wmPtr->cmdArgc); - offsets = (int *) ckalloc( sizeof(int) * wmPtr->cmdArgc); + cmdArgv = ckalloc(sizeof(char *) * wmPtr->cmdArgc); + offsets = ckalloc(sizeof(int) * wmPtr->cmdArgc); Tcl_DStringInit(&cmds); for (i = 0; i < wmPtr->cmdArgc; i++) { Tcl_UtfToExternalDString(NULL, wmPtr->cmdArgv[i], -1, &ds); @@ -7231,8 +7230,8 @@ UpdateCommand( XSetCommand(winPtr->display, wmPtr->wrapperPtr->window, cmdArgv, wmPtr->cmdArgc); Tcl_DStringFree(&cmds); - ckfree((char *) cmdArgv); - ckfree((char *) offsets); + ckfree(cmdArgv); + ckfree(offsets); } /* 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--; @@ -52,7 +52,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; if (clip_mask == None) { - clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); + clip_mask = ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK } else if (clip_mask->type == TKP_CLIP_REGION) { @@ -85,7 +85,7 @@ static void FreeClipMask(GC gc) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif - ckfree((char*) gc->clip_mask); + ckfree(gc->clip_mask); gc->clip_mask = None; } } @@ -124,8 +124,7 @@ XCreateGC( #define MAX_DASH_LIST_SIZE 10 - gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + - gcCacheSize); + gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { return None; } @@ -272,7 +271,7 @@ void XFreeGC( if (gc != None) { FreeClipMask(gc); TkpFreeGCCache(gc); - ckfree((char *) gc); + ckfree(gc); } } diff --git a/xlib/xutil.c b/xlib/xutil.c index d5e26eb..b265e5d 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -70,7 +70,7 @@ XGetVisualInfo( XVisualInfo *vinfo_template, int *nitems_return) { - XVisualInfo *info = (XVisualInfo *) ckalloc(sizeof(XVisualInfo)); + XVisualInfo *info = ckalloc(sizeof(XVisualInfo)); info->visual = DefaultVisual(display, 0); info->visualid = info->visual->visualid; @@ -102,7 +102,7 @@ XGetVisualInfo( || ((vinfo_mask & VisualBlueMaskMask) && (vinfo_template->blue_mask != info->blue_mask)) ) { - ckfree((char *) info); + ckfree(info); return NULL; } |