summaryrefslogtreecommitdiffstats
path: root/generic/tkColor.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-12-09 22:38:21 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-12-09 22:38:21 (GMT)
commit1f59371cb00eaad072355062191091c548627a28 (patch)
tree91a0c48dafb00dbb2c71f729a411c70485112642 /generic/tkColor.c
parent71f8c03a9e6e3a17786a6c0b121629aff69004a3 (diff)
downloadtk-1f59371cb00eaad072355062191091c548627a28.zip
tk-1f59371cb00eaad072355062191091c548627a28.tar.gz
tk-1f59371cb00eaad072355062191091c548627a28.tar.bz2
Apply [Bug 2911570]'s patch to make color value hashing work on 64-bit.
Diffstat (limited to 'generic/tkColor.c')
-rw-r--r--generic/tkColor.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 85593ac..d17b393 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkColor.c,v 1.16 2007/12/13 15:24:13 dgp Exp $
+ * RCS: @(#) $Id: tkColor.c,v 1.16.2.1 2009/12/09 22:38:22 dkf Exp $
*/
#include "tkInt.h"
@@ -129,8 +129,8 @@ Tk_AllocColorFromObj(
*/
if (tkColPtr != NULL) {
- TkColor *firstColorPtr = (TkColor *)
- Tcl_GetHashValue(tkColPtr->hashPtr);
+ TkColor *firstColorPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+
FreeColorObjProc(objPtr);
for (tkColPtr = firstColorPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
@@ -204,7 +204,7 @@ Tk_GetColor(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->colorNameTable, name, &isNew);
if (!isNew) {
- existingColPtr = (TkColor *) Tcl_GetHashValue(nameHashPtr);
+ existingColPtr = Tcl_GetHashValue(nameHashPtr);
for (tkColPtr = existingColPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
if ((tkColPtr->screen == Tk_Screen(tkwin))
@@ -300,8 +300,11 @@ Tk_GetColorByValue(
/*
* First, check to see if there's already a mapping for this color name.
+ * Must clear the structure first; it's not tightly packed on 64-bit
+ * systems. [Bug 2911570]
*/
+ memset(&valueKey, 0, sizeof(ValueKey));
valueKey.red = colorPtr->red;
valueKey.green = colorPtr->green;
valueKey.blue = colorPtr->blue;
@@ -310,7 +313,7 @@ Tk_GetColorByValue(
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->colorValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- tkColPtr = (TkColor *) Tcl_GetHashValue(valueHashPtr);
+ tkColPtr = Tcl_GetHashValue(valueHashPtr);
tkColPtr->resourceRefCount++;
return &tkColPtr->color;
}
@@ -474,7 +477,7 @@ Tk_FreeColor(
}
TkpFreeColor(tkColPtr);
- prevPtr = (TkColor *) Tcl_GetHashValue(tkColPtr->hashPtr);
+ prevPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
if (prevPtr == tkColPtr) {
if (tkColPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(tkColPtr->hashPtr);
@@ -664,7 +667,7 @@ Tk_GetColorFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (tkColPtr = (TkColor *) Tcl_GetHashValue(hashPtr);
+ for (tkColPtr = Tcl_GetHashValue(hashPtr);
(tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) {
if ((Tk_Screen(tkwin) == tkColPtr->screen)
&& (Tk_Colormap(tkwin) == tkColPtr->colormap)) {
@@ -780,7 +783,7 @@ TkDebugColor(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name);
if (hashPtr != NULL) {
- TkColor *tkColPtr = (TkColor *) Tcl_GetHashValue(hashPtr);
+ TkColor *tkColPtr = Tcl_GetHashValue(hashPtr);
if (tkColPtr == NULL) {
Tcl_Panic("TkDebugColor found empty hash table entry");