summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-11-05 12:04:26 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-11-05 12:04:26 (GMT)
commitf58782e964943a3a977716bf65ee3b6cedafde06 (patch)
treed07a21bbd6bd79fea3cdcf68e03c74b63f29d59d
parentf82b718e135c44bb8bb4865ac5cbb0272502de66 (diff)
parent2da9e225ec7604a5ad4e4dc46e76d090d733b87c (diff)
downloadtk-f58782e964943a3a977716bf65ee3b6cedafde06.zip
tk-f58782e964943a3a977716bf65ee3b6cedafde06.tar.gz
tk-f58782e964943a3a977716bf65ee3b6cedafde06.tar.bz2
Close unintended fork
-rw-r--r--generic/tkConfig.c21
-rw-r--r--generic/tkConsole.c12
-rw-r--r--generic/tkFont.c5
-rw-r--r--unix/tkUnixFont.c15
4 files changed, 25 insertions, 28 deletions
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 9c159e6..093bd35 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -91,7 +91,7 @@ typedef struct TkOption {
*/
typedef struct OptionTable {
- int refCount; /* Counts the number of uses of this table
+ size_t refCount; /* Counts the number of uses of this table
* (the number of times Tk_CreateOptionTable
* has returned it). This can be greater than
* 1 if it is shared along several option
@@ -103,7 +103,7 @@ typedef struct OptionTable {
* templates, this points to the table
* corresponding to the next template in the
* chain. */
- int numOptions; /* The number of items in the options array
+ size_t numOptions; /* The number of items in the options array
* below. */
Option options[1]; /* Information about the individual options in
* the table. This must be the last field in
@@ -177,7 +177,7 @@ Tk_CreateOptionTable(
OptionTable *tablePtr;
const Tk_OptionSpec *specPtr, *specPtr2;
Option *optionPtr;
- int numOptions, i;
+ size_t numOptions, i;
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -330,10 +330,9 @@ Tk_DeleteOptionTable(
{
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
- tablePtr->refCount--;
- if (tablePtr->refCount > 0) {
+ if (tablePtr->refCount-- > 1) {
return;
}
@@ -978,7 +977,7 @@ GetOption(
Option *bestPtr, *optionPtr;
OptionTable *tablePtr2;
const char *p1, *p2;
- int count;
+ size_t count;
/*
* Search through all of the option tables in the chain to find the best
@@ -1539,7 +1538,7 @@ Tk_FreeConfigOptions(
{
OptionTable *tablePtr;
Option *optionPtr;
- int count;
+ size_t count;
Tcl_Obj **oldPtrPtr, *oldPtr;
char *oldInternalPtr;
const Tk_OptionSpec *specPtr;
@@ -1733,7 +1732,7 @@ Tk_GetOptionInfo(
Tcl_Obj *resultPtr;
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
/*
* If information is only wanted for a single configuration spec, then
@@ -2096,9 +2095,9 @@ TkDebugConfig(
if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) {
for ( ; tablePtr != NULL; tablePtr = tablePtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->refCount));
+ Tcl_NewWideIntObj(tablePtr->refCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->numOptions));
+ Tcl_NewWideIntObj(tablePtr->numOptions));
Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj(
tablePtr->options[0].specPtr->optionName, -1));
}
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index 8bfbe9b..fc60d5f 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -24,7 +24,7 @@
typedef struct ConsoleInfo {
Tcl_Interp *consoleInterp; /* Interpreter displaying the console. */
Tcl_Interp *interp; /* Interpreter controlled by console. */
- int refCount;
+ size_t refCount;
} ConsoleInfo;
/*
@@ -452,7 +452,7 @@ Tk_CreateConsoleWindow(
if (mainWindow) {
Tk_DeleteEventHandler(mainWindow, StructureNotifyMask,
ConsoleEventProc, info);
- if (--info->refCount <= 0) {
+ if (info->refCount-- <= 1) {
ckfree(info);
}
}
@@ -592,7 +592,7 @@ ConsoleClose(
ConsoleInfo *info = data->info;
if (info) {
- if (--info->refCount <= 0) {
+ if (info->refCount-- <= 1) {
/*
* Assuming the Tcl_Interp * fields must already be NULL.
*/
@@ -881,7 +881,7 @@ InterpDeleteProc(
Tcl_DeleteThreadExitHandler(DeleteConsoleInterp, info->consoleInterp);
info->consoleInterp = NULL;
}
- if (--info->refCount <= 0) {
+ if (info->refCount-- <= 1) {
ckfree(info);
}
}
@@ -912,7 +912,7 @@ ConsoleDeleteProc(
if (info->consoleInterp) {
Tcl_DeleteInterp(info->consoleInterp);
}
- if (--info->refCount <= 0) {
+ if (info->refCount-- <= 1) {
ckfree(info);
}
}
@@ -949,7 +949,7 @@ ConsoleEventProc(
Tcl_EvalEx(consoleInterp, "tk::ConsoleExit", -1, TCL_EVAL_GLOBAL);
}
- if (--info->refCount <= 0) {
+ if (info->refCount-- <= 1) {
ckfree(info);
}
}
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 7f2715b..a00c627 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -41,7 +41,7 @@ typedef struct TkFontInfo {
*/
typedef struct NamedFont {
- int refCount; /* Number of users of named font. */
+ size_t refCount; /* Number of users of named font. */
int deletePending; /* Non-zero if font should be deleted when
* last reference goes away. */
TkFontAttributes fa; /* Desired attributes for named font. */
@@ -1434,8 +1434,7 @@ Tk_FreeFont(
*/
nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr);
- nfPtr->refCount--;
- if ((nfPtr->refCount == 0) && nfPtr->deletePending) {
+ if ((nfPtr->refCount-- <= 1) && nfPtr->deletePending) {
Tcl_DeleteHashEntry(fontPtr->namedHashPtr);
ckfree(nfPtr);
}
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index e694573..c96e562 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -19,8 +19,8 @@
* The preferred font encodings.
*/
-static const char *const encodingList[] = {
- "iso8859-1", "jis0208", "jis0212", NULL
+static const char encodingList[][10] = {
+ "iso8859-1", "jis0208", "jis0212"
};
/*
@@ -42,7 +42,7 @@ static const char *const encodingList[] = {
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. */
/*
@@ -1916,8 +1916,7 @@ FreeFontFamily(
if (familyPtr == NULL) {
return;
}
- familyPtr->refCount--;
- if (familyPtr->refCount > 0) {
+ if (familyPtr->refCount-- > 1) {
return;
}
Tcl_FreeEncoding(familyPtr->encoding);
@@ -2686,7 +2685,7 @@ RankAttributes(
penalty += 150 * diff;
}
if (gotPtr->xa.charset != wantPtr->xa.charset) {
- int i;
+ size_t i;
const char *gotAlias, *wantAlias;
penalty += 65000;
@@ -2694,7 +2693,7 @@ RankAttributes(
wantAlias = GetEncodingAlias(wantPtr->xa.charset);
if (strcmp(gotAlias, wantAlias) != 0) {
penalty += 30000;
- for (i = 0; encodingList[i] != NULL; i++) {
+ for (i = 0; i < sizeof(encodingList)/sizeof(encodingList[0]); i++) {
if (strcmp(gotAlias, encodingList[i]) == 0) {
penalty -= 30000;
break;
@@ -3012,7 +3011,7 @@ static const char *
GetEncodingAlias(
const char *name) /* The name to look up. */
{
- EncodingAlias *aliasPtr;
+ const EncodingAlias *aliasPtr;
for (aliasPtr = encodingAliases; aliasPtr->aliasPattern != NULL; ) {
if (Tcl_StringMatch(name, aliasPtr->aliasPattern)) {