summaryrefslogtreecommitdiffstats
path: root/win/tkWinColor.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-08 07:54:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-08 07:54:08 (GMT)
commit973b6e6d17b26ec027eb3b6df3b37d9da9d9f514 (patch)
tree16cd8e062060db885208ea156a7c74aa9751ee83 /win/tkWinColor.c
parent649ce6ba5bb32fc38e88fc8f4ac13359651d1d32 (diff)
downloadtk-973b6e6d17b26ec027eb3b6df3b37d9da9d9f514.zip
tk-973b6e6d17b26ec027eb3b6df3b37d9da9d9f514.tar.gz
tk-973b6e6d17b26ec027eb3b6df3b37d9da9d9f514.tar.bz2
Use size_t in stead of int for some internal refCount variables. On 32-bit systems, this doubles the range (as size_t is unsigned), on 64-bit system much more than that.
Diffstat (limited to 'win/tkWinColor.c')
-rw-r--r--win/tkWinColor.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/win/tkWinColor.c b/win/tkWinColor.c
index 5eaeeb3..ba9815c 100644
--- a/win/tkWinColor.c
+++ b/win/tkWinColor.c
@@ -316,7 +316,8 @@ XAllocColor(
if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
unsigned long sizePalette = GetDeviceCaps(dc, SIZEPALETTE);
UINT newPixel, closePixel;
- int new, refCount;
+ int new;
+ size_t refCount;
Tcl_HashEntry *entryPtr;
UINT index;
@@ -361,9 +362,9 @@ XAllocColor(
if (new) {
refCount = 1;
} else {
- refCount = (PTR2INT(Tcl_GetHashValue(entryPtr))) + 1;
+ refCount = (size_t)Tcl_GetHashValue(entryPtr) + 1;
}
- Tcl_SetHashValue(entryPtr, INT2PTR(refCount));
+ Tcl_SetHashValue(entryPtr, (void *)refCount);
} else {
/*
* Determine what color will actually be used on non-colormap systems.
@@ -407,7 +408,8 @@ XFreeColors(
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
COLORREF cref;
- UINT count, index, refCount;
+ UINT count, index;
+ size_t refCount;
int i;
PALETTEENTRY entry, *entries;
Tcl_HashEntry *entryPtr;
@@ -427,7 +429,7 @@ XFreeColors(
if (!entryPtr) {
Tcl_Panic("Tried to free a color that isn't allocated");
}
- refCount = PTR2INT(Tcl_GetHashValue(entryPtr)) - 1;
+ refCount = (size_t)Tcl_GetHashValue(entryPtr) - 1;
if (refCount == 0) {
cref = pixels[i] & 0x00ffffff;
index = GetNearestPaletteIndex(cmap->palette, cref);
@@ -444,7 +446,7 @@ XFreeColors(
}
Tcl_DeleteHashEntry(entryPtr);
} else {
- Tcl_SetHashValue(entryPtr, INT2PTR(refCount));
+ Tcl_SetHashValue(entryPtr, (size_t)refCount);
}
}
}