summaryrefslogtreecommitdiffstats
path: root/generic/tkConfig.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-15 18:55:40 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-15 18:55:40 (GMT)
commit2c6df21a22544260bc790e12db7c701c7653d376 (patch)
tree3ca1975f0f5ea52919dd11f5f9b3d7a2695cbbdb /generic/tkConfig.c
parentfe2b267ee9d5dff5839a3d018e8a200c2dd368ba (diff)
downloadtk-2c6df21a22544260bc790e12db7c701c7653d376.zip
tk-2c6df21a22544260bc790e12db7c701c7653d376.tar.gz
tk-2c6df21a22544260bc790e12db7c701c7653d376.tar.bz2
Use more size_t internally, comparable with TIP #494 but then in Tk. Eliminate unnecessary type casts
Diffstat (limited to 'generic/tkConfig.c')
-rw-r--r--generic/tkConfig.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 4e90fab..d0802f3 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -115,14 +115,14 @@ typedef struct OptionTable {
* Forward declarations for functions defined later in this file:
*/
-static int DoObjConfig(Tcl_Interp *interp, char *recordPtr,
+static int DoObjConfig(Tcl_Interp *interp, void *recordPtr,
Option *optionPtr, Tcl_Obj *valuePtr,
Tk_Window tkwin, Tk_SavedOption *savePtr);
static void FreeResources(Option *optionPtr, Tcl_Obj *objPtr,
- char *internalPtr, Tk_Window tkwin);
-static Tcl_Obj * GetConfigList(char *recordPtr,
+ void *internalPtr, Tk_Window tkwin);
+static Tcl_Obj * GetConfigList(void *recordPtr,
Option *optionPtr, Tk_Window tkwin);
-static Tcl_Obj * GetObjectForOption(char *recordPtr,
+static Tcl_Obj * GetObjectForOption(void *recordPtr,
Option *optionPtr, Tk_Window tkwin);
static Option * GetOption(const char *name, OptionTable *tablePtr);
static Option * GetOptionFromObj(Tcl_Interp *interp,
@@ -279,7 +279,7 @@ Tk_CreateOptionTable(
}
}
if (((specPtr->type == TK_OPTION_STRING)
- && (specPtr->internalOffset >= 0))
+ && (specPtr->internalOffset != TCL_AUTO_LENGTH))
|| (specPtr->type == TK_OPTION_COLOR)
|| (specPtr->type == TK_OPTION_FONT)
|| (specPtr->type == TK_OPTION_BITMAP)
@@ -552,7 +552,7 @@ DoObjConfig(
Tcl_Interp *interp, /* Interpreter for error reporting. If NULL,
* then no message is left if an error
* occurs. */
- char *recordPtr, /* The record to modify to hold the new option
+ void *recordPtr, /* The record to modify to hold the new option
* value. */
Option *optionPtr, /* Pointer to information about the option. */
Tcl_Obj *valuePtr, /* New value for option. */
@@ -568,10 +568,10 @@ DoObjConfig(
* free the old value). */
{
Tcl_Obj **slotPtrPtr, *oldPtr;
- char *internalPtr; /* Points to location in record where internal
+ void *internalPtr; /* Points to location in record where internal
* representation of value should be stored,
* or NULL. */
- char *oldInternalPtr; /* Points to location in which to save old
+ void *oldInternalPtr; /* Points to location in which to save old
* internal representation of value. */
Tk_SavedOption internal; /* Used to save the old internal
* representation of the value if
@@ -584,7 +584,7 @@ DoObjConfig(
*/
specPtr = optionPtr->specPtr;
- if (specPtr->objOffset >= 0) {
+ if (specPtr->objOffset != TCL_AUTO_LENGTH) {
slotPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset);
oldPtr = *slotPtrPtr;
} else {
@@ -597,7 +597,7 @@ DoObjConfig(
* object and internal forms, if they exist.
*/
- if (specPtr->internalOffset >= 0) {
+ if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
internalPtr = recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
@@ -1340,7 +1340,7 @@ Tk_RestoreSavedOptions(
Tk_SavedOptions *savePtr) /* Holds saved option information; must have
* been passed to Tk_SetOptions. */
{
- int i;
+ size_t i;
Option *optionPtr;
Tcl_Obj *newPtr; /* New object value of option, which we
* replace with old value and free. Taken from
@@ -1360,7 +1360,7 @@ Tk_RestoreSavedOptions(
ckfree(savePtr->nextPtr);
savePtr->nextPtr = NULL;
}
- for (i = savePtr->numItems - 1; i >= 0; i--) {
+ for (i = savePtr->numItems - 1; i != (size_t)-1; i--) {
optionPtr = savePtr->items[i].optionPtr;
specPtr = optionPtr->specPtr;
@@ -1369,12 +1369,12 @@ Tk_RestoreSavedOptions(
* record.
*/
- if (specPtr->objOffset >= 0) {
+ if (specPtr->objOffset != TCL_AUTO_LENGTH) {
newPtr = *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset));
} else {
newPtr = NULL;
}
- if (specPtr->internalOffset >= 0) {
+ if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
internalPtr = savePtr->recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
@@ -1390,11 +1390,11 @@ Tk_RestoreSavedOptions(
* Now restore the old value of the option.
*/
- if (specPtr->objOffset >= 0) {
+ if (specPtr->objOffset != TCL_AUTO_LENGTH) {
*((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset))
= savePtr->items[i].valuePtr;
}
- if (specPtr->internalOffset >= 0) {
+ if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
register char *ptr = (char *) &savePtr->items[i].internalForm;
CLANG_ASSERT(internalPtr);
@@ -1487,7 +1487,7 @@ Tk_FreeSavedOptions(
Tk_SavedOptions *savePtr) /* Contains options saved in a previous call
* to Tk_SetOptions. */
{
- int count;
+ size_t count;
Tk_SavedOption *savedOptionPtr;
if (savePtr->nextPtr != NULL) {
@@ -1537,7 +1537,7 @@ Tk_FreeConfigOptions(
Option *optionPtr;
size_t count;
Tcl_Obj **oldPtrPtr, *oldPtr;
- char *oldInternalPtr;
+ void *oldInternalPtr;
const Tk_OptionSpec *specPtr;
for (tablePtr = (OptionTable *) optionTable; tablePtr != NULL;
@@ -1548,14 +1548,14 @@ Tk_FreeConfigOptions(
if (specPtr->type == TK_OPTION_SYNONYM) {
continue;
}
- if (specPtr->objOffset >= 0) {
+ if (specPtr->objOffset != TCL_AUTO_LENGTH) {
oldPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset);
oldPtr = *oldPtrPtr;
*oldPtrPtr = NULL;
} else {
oldPtr = NULL;
}
- if (specPtr->internalOffset >= 0) {
+ if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
oldInternalPtr = recordPtr + specPtr->internalOffset;
} else {
oldInternalPtr = NULL;
@@ -1593,10 +1593,10 @@ FreeResources(
Option *optionPtr, /* Description of the configuration option. */
Tcl_Obj *objPtr, /* The current value of the option, specified
* as an object. */
- char *internalPtr, /* A pointer to an internal representation for
+ void *internalPtr, /* A pointer to an internal representation for
* the option's value, such as an int or
* (XColor *). Only valid if
- * optionPtr->specPtr->internalOffset >= 0. */
+ * optionPtr->specPtr->internalOffset != -1. */
Tk_Window tkwin) /* The window in which this option is used. */
{
int internalFormExists;
@@ -1607,7 +1607,7 @@ FreeResources(
* form, then use the object form.
*/
- internalFormExists = optionPtr->specPtr->internalOffset >= 0;
+ internalFormExists = optionPtr->specPtr->internalOffset != TCL_AUTO_LENGTH;
switch (optionPtr->specPtr->type) {
case TK_OPTION_STRING:
if (internalFormExists) {
@@ -1781,7 +1781,7 @@ Tk_GetOptionInfo(
static Tcl_Obj *
GetConfigList(
- char *recordPtr, /* Pointer to record holding current values of
+ void *recordPtr, /* Pointer to record holding current values of
* configuration options. */
Option *optionPtr, /* Pointer to information describing a
* particular option. */
@@ -1824,7 +1824,7 @@ GetConfigList(
}
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
- if (optionPtr->specPtr->objOffset >= 0) {
+ if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) {
elementPtr = *((Tcl_Obj **) (recordPtr
+ optionPtr->specPtr->objOffset));
if (elementPtr == NULL) {
@@ -1859,7 +1859,7 @@ GetConfigList(
static Tcl_Obj *
GetObjectForOption(
- char *recordPtr, /* Pointer to record holding current values of
+ void *recordPtr, /* Pointer to record holding current values of
* configuration options. */
Option *optionPtr, /* Pointer to information describing an option
* whose internal value is stored in
@@ -1867,7 +1867,7 @@ GetObjectForOption(
Tk_Window tkwin) /* Window corresponding to recordPtr. */
{
Tcl_Obj *objPtr;
- char *internalPtr; /* Points to internal value of option in
+ void *internalPtr; /* Points to internal value of option in
* record. */
internalPtr = recordPtr + optionPtr->specPtr->internalOffset;
@@ -2019,7 +2019,7 @@ Tk_GetOptionValue(
if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) {
optionPtr = optionPtr->extra.synonymPtr;
}
- if (optionPtr->specPtr->objOffset >= 0) {
+ if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) {
resultPtr = *((Tcl_Obj **) (recordPtr+optionPtr->specPtr->objOffset));
if (resultPtr == NULL) {
/*