Diff

Differences From Artifact [e3ba0e89d2]:

To Artifact [7ccc07ce2d]:


    79     79   	const char *fmt;
    80     80   };
    81     81   
    82     82   static Tcl_Interp *appfs_create_TclInterp(const char *cachedir) {
    83     83   	Tcl_Interp *interp;
    84     84   	int tcl_ret;
    85     85   
           86  +	APPFS_DEBUG("Creating new Tcl interpreter for TID = 0x%llx", (unsigned long long) pthread_self());
           87  +
    86     88   	interp = Tcl_CreateInterp();
    87     89   	if (interp == NULL) {
    88     90   		fprintf(stderr, "Unable to create Tcl Interpreter.  Aborting.\n");
    89     91   
    90     92   		return(NULL);
    91     93   	}
    92     94   
    93     95   	tcl_ret = Tcl_Init(interp);
    94     96   	if (tcl_ret != TCL_OK) {
    95     97   		fprintf(stderr, "Unable to initialize Tcl.  Aborting.\n");
           98  +
           99  +		Tcl_DeleteInterp(interp);
    96    100   
    97    101   		return(NULL);
    98    102   	}
    99    103   
   100    104   	tcl_ret = Tcl_Eval(interp, ""
   101    105   #include "appfsd.tcl.h"
   102    106   	"");
   103    107   	if (tcl_ret != TCL_OK) {
   104    108   		fprintf(stderr, "Unable to initialize Tcl AppFS script.  Aborting.\n");
   105    109   		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
   106    110   
          111  +		Tcl_DeleteInterp(interp);
          112  +
   107    113   		return(NULL);
   108    114   	}
   109    115   
   110    116   	if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) {
   111    117   		fprintf(stderr, "Unable to set cache directory.  This should never fail.\n");
          118  +
          119  +		Tcl_DeleteInterp(interp);
   112    120   
   113    121   		return(NULL);
   114    122   	}
   115    123   
   116    124   	tcl_ret = Tcl_Eval(interp, "::appfs::init");
   117    125   	if (tcl_ret != TCL_OK) {
   118    126   		fprintf(stderr, "Unable to initialize Tcl AppFS script (::appfs::init).  Aborting.\n");
   119    127   		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
   120    128   
          129  +		Tcl_DeleteInterp(interp);
          130  +
   121    131   		return(NULL);
   122    132   	}
          133  +
          134  +	Tcl_HideCommand(interp, "package", "package");
          135  +	Tcl_HideCommand(interp, "glob", "glob");
          136  +	Tcl_HideCommand(interp, "exec", "exec");
          137  +	Tcl_HideCommand(interp, "pid", "pid");
          138  +	Tcl_HideCommand(interp, "auto_load_index", "auto_load_index");
          139  +	Tcl_HideCommand(interp, "unknown", "unknown");
   123    140   
   124    141   	return(interp);
   125    142   }
   126    143   
   127    144   static int appfs_Tcl_Eval(Tcl_Interp *interp, int objc, const char *cmd, ...) {
   128    145   	Tcl_Obj **objv;
   129    146   	const char *arg;