Tcl Source Code

Check-in [5c01d3bd75]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use iPtr field instead of source field to mark a CompileEnv as uninitialized. envPtr->source == NULL can actually be valid (at least when merging forward).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: 5c01d3bd7537fc31c5f1f7724faa47fb5252abb4
User & Date: dgp 2013-02-22 18:24:24
Context
2013-02-25
18:05
Repair linked list management in Tcl_DeleteCloseHandler(). CloseCallback struct is used only locall... check-in: 5a27ca7124 user: dgp tags: core-8-4-branch
2013-02-22
18:26
Shift more burden of smart cleanup onto the TclFreeCompileEnv() routine. Stop crashes when the hookP... check-in: 06abbd6e02 user: dgp tags: core-8-5-branch
18:24
Use iPtr field instead of source field to mark a CompileEnv as uninitialized. envPtr->source == NULL... check-in: 5c01d3bd75 user: dgp tags: core-8-4-branch
17:38
Shift more burden of smart cleanup onto the TclFreeCompileEnv() routine. Stop crashes when the hookP... check-in: 4b47ba25b7 user: dgp tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclCompile.c.

918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
 *----------------------------------------------------------------------
 */

void
TclFreeCompileEnv(envPtr)
    register CompileEnv *envPtr; /* Points to the CompileEnv structure. */
{
    if (envPtr->source) {
	/* 
	 * We never converted to Bytecode, so free the things we would
	 * have transferred to it.
	 */

	int i;
	LiteralEntry *entryPtr = envPtr->literalArrayPtr;







|







918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
 *----------------------------------------------------------------------
 */

void
TclFreeCompileEnv(envPtr)
    register CompileEnv *envPtr; /* Points to the CompileEnv structure. */
{
    if (envPtr->iPtr) {
	/* 
	 * We never converted to Bytecode, so free the things we would
	 * have transferred to it.
	 */

	int i;
	LiteralEntry *entryPtr = envPtr->literalArrayPtr;
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
    /* TIP #280 */
    ExtCmdLoc* eclPtr = envPtr->extCmdMapPtr;
    int* wlines = NULL;
    int  wlineat, cmdLine;
    int* clNext;
#endif

    if (envPtr->source == NULL) {
	Tcl_Panic("TclCompileScript() called on uninitialized CompileEnv");
    }

    Tcl_DStringInit(&ds);

    if (numBytes < 0) {
	numBytes = strlen(script);







|







1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
    /* TIP #280 */
    ExtCmdLoc* eclPtr = envPtr->extCmdMapPtr;
    int* wlines = NULL;
    int  wlineat, cmdLine;
    int* clNext;
#endif

    if (envPtr->iPtr == NULL) {
	Tcl_Panic("TclCompileScript() called on uninitialized CompileEnv");
    }

    Tcl_DStringInit(&ds);

    if (numBytes < 0) {
	numBytes = strlen(script);
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
    Namespace *namespacePtr;
    int i;
#ifdef TCL_TIP280
    int new;
#endif
    Interp *iPtr;

    if (envPtr->source == NULL) {
	Tcl_Panic("TclInitByteCodeObj() called on uninitialized CompileEnv");
    }

    iPtr = envPtr->iPtr;

    codeBytes = (envPtr->codeNext - envPtr->codeStart);
    objArrayBytes = (envPtr->literalArrayNext * sizeof(Tcl_Obj *));







|







1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
    Namespace *namespacePtr;
    int i;
#ifdef TCL_TIP280
    int new;
#endif
    Interp *iPtr;

    if (envPtr->iPtr == NULL) {
	Tcl_Panic("TclInitByteCodeObj() called on uninitialized CompileEnv");
    }

    iPtr = envPtr->iPtr;

    codeBytes = (envPtr->codeNext - envPtr->codeStart);
    objArrayBytes = (envPtr->literalArrayNext * sizeof(Tcl_Obj *));
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131

    Tcl_SetHashValue (Tcl_CreateHashEntry (iPtr->lineBCPtr, (char*) codePtr, &new),
		      envPtr->extCmdMapPtr);
    envPtr->extCmdMapPtr = NULL;
#endif

    /* We've used up the CompileEnv.  Mark as uninitialized. */
    envPtr->source = NULL;
}

/*
 *----------------------------------------------------------------------
 *
 * LogCompilationInfo --
 *







|







2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131

    Tcl_SetHashValue (Tcl_CreateHashEntry (iPtr->lineBCPtr, (char*) codePtr, &new),
		      envPtr->extCmdMapPtr);
    envPtr->extCmdMapPtr = NULL;
#endif

    /* We've used up the CompileEnv.  Mark as uninitialized. */
    envPtr->iPtr = NULL;
}

/*
 *----------------------------------------------------------------------
 *
 * LogCompilationInfo --
 *