int RivetCache_StoreScript()

in src/mod_rivet_ng/mod_rivet_cache.c [232:261]


int RivetCache_StoreScript(rivet_thread_interp* rivet_interp, Tcl_HashEntry* entry, Tcl_Obj* script)
{
    if (rivet_interp->cache_size) {

        if (rivet_interp->cache_free) {
            char* hashKey = (char *) Tcl_GetHashKey (rivet_interp->objCache,entry);

            /* 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);
            Tcl_SetHashValue (entry,(ClientData)script);

            rivet_interp->objCacheList[--rivet_interp->cache_free] =
                (char*) apr_pcalloc (rivet_interp->pool,(strlen(hashKey)+1)*sizeof(char));
            strcpy(rivet_interp->objCacheList[rivet_interp->cache_free], hashKey);

            return 0;

        } else {
            /* cache full */

            return 1;
        }

    }
    return 0;
}