summaryrefslogtreecommitdiffstats
path: root/win
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
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')
-rw-r--r--win/tkWinColor.c14
-rw-r--r--win/tkWinFont.c5
-rw-r--r--win/tkWinWm.c6
3 files changed, 12 insertions, 13 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);
}
}
}
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 86f63ac..9172b00 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -33,7 +33,7 @@
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
- int refCount; /* How many SubFonts are referring to this
+ size_t refCount; /* How many SubFonts are referring to this
* FontFamily. When the refCount drops to
* zero, this FontFamily may be freed. */
/*
@@ -1869,8 +1869,7 @@ FreeFontFamily(
if (familyPtr == NULL) {
return;
}
- familyPtr->refCount--;
- if (familyPtr->refCount > 0) {
+ if (familyPtr->refCount-- > 1) {
return;
}
for (i = 0; i < FONTMAP_PAGES; i++) {
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 4d46fd5..768ee69 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -148,7 +148,7 @@ typedef struct {
*/
typedef struct WinIconInstance {
- int refCount; /* Number of instances that share this data
+ size_t refCount; /* Number of instances that share this data
* structure. */
BlockOfIconImagesPtr iconBlock;
/* Pointer to icon resource data for image */
@@ -1421,9 +1421,7 @@ static void
DecrIconRefCount(
WinIconPtr titlebaricon)
{
- titlebaricon->refCount--;
-
- if (titlebaricon->refCount <= 0) {
+ if (titlebaricon->refCount-- <= 1) {
if (titlebaricon->iconBlock != NULL) {
FreeIconBlock(titlebaricon->iconBlock);
}