You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/05/24 11:05:23 UTC

[tcl-rivet] branch quattuor updated: Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code

This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch quattuor
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git


The following commit(s) were added to refs/heads/quattuor by this push:
     new 26d1c85  Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
26d1c85 is described below

commit 26d1c85ae55ea31641c3bacb2f96debd4622bed7
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Fri May 24 12:48:02 2019 +0200

    Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
---
 ChangeLog                          | 5 +++++
 src/mod_rivet_ng/mod_rivet_cache.c | 6 +++---
 src/mod_rivet_ng/rivetCore.c       | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 182041d..11bdbd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-24 Massimo Manghi <mx...@apache.org>
+    * src/mod_rivet_ng/rivetCore.c: Add Tcl_DecrRefCnt after
+    RivetCache_StoreScript as this function itself calls
+    Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
+    
 2019-04-16 Massimo Manghi <mx...@apache.org>
     * src/mod_rivet_ng/: also the worker and lazy bridge transitioned to 
     the new interpreter model
diff --git a/src/mod_rivet_ng/mod_rivet_cache.c b/src/mod_rivet_ng/mod_rivet_cache.c
index 9371a36..721c8d9 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.c
+++ b/src/mod_rivet_ng/mod_rivet_cache.c
@@ -198,9 +198,9 @@ int RivetCache_StoreScript(rivet_thread_interp* rivet_interp, Tcl_HashEntry* ent
         if (rivet_interp->cache_free) {
             char* hashKey = (char *) Tcl_GetHashKey (rivet_interp->objCache,entry);
 
-            /* We need to incr the reference count of outbuf because we want
-             * it to outlive this function.  This allows it to stay alive
-             * as long as it's in the object cache.
+            /* Tcl_SetHashValue is a macro that simply stuffs the value pointer in an array
+             * We need to incr the reference count of outbuf because we want it to outlive 
+             * this function and be kept as long as the cache is preserved
              */
 
             Tcl_IncrRefCount (script);
diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c
index 4ef8de0..7982bf0 100644
--- a/src/mod_rivet_ng/rivetCore.c
+++ b/src/mod_rivet_ng/rivetCore.c
@@ -307,12 +307,12 @@ TCL_CMD_HEADER( Rivet_Parse )
         }
         
         RivetCache_StoreScript(rivet_interp,entry,script);
+        Tcl_DecrRefCount(script);
     } else {
         script = RivetCache_FetchScript(entry);
     }
 
     return Tcl_EvalObjEx(interp,script,0); 
-    //return Rivet_ParseExecFile(private,filename,0);
 }
 
 /*


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org