Example #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// TreeCache::CacheResize():
//
void
TreeCache::CacheResize (uint size)
{
    // If cache size decreases, simply reset it
    if (CacheSize > size) {
      SetCacheSize(size);
      return;
    }

    cachedTreeT* oldCache = Cache;
    uint oldSize = CacheSize;

#ifdef WINCE
    Cache = (cachedTreeT*) my_Tcl_Alloc( sizeof(cachedTreeT [size]));
#else
    Cache = new cachedTreeT [size];
#endif

    CacheSize = size;
    // Clear all the filters and nodes so they dont contain garbage:
    for (uint i=0; i < size; i++) {
        cachedTreeT * ctree = &(Cache[i]);
        ctree->cfilter = NULL;
        for (uint count = 0; count < MAX_TREE_NODES; count++) {
            initTreeNode (&(ctree->tree.node[count]));
        }
    }

    // copy old data to new Cache
    for (uint i=0; i < oldSize; i++) {
        cachedTreeT * ctree = &(oldCache[i]);
        Cache[i] = *ctree;
    }
}
Example #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// TreeCache::SetCacheSize():
//
void
TreeCache::SetCacheSize (uint size)
{
    if (CacheSize > 0) { Delete(); }
#ifdef WINCE
    Cache = (cachedTreeT*) my_Tcl_Alloc( sizeof(cachedTreeT [size]));
#else
    Cache = new cachedTreeT [size];
#endif

    CacheSize = size;
    NumInUse = 0;
    MostRecentIndex = 0;
    // Clear all the filters and nodes so they dont contain garbage:
    for (uint i=0; i < size; i++) {
        cachedTreeT * ctree = &(Cache[i]);
        ctree->cfilter = NULL;
        for (uint count = 0; count < MAX_TREE_NODES; count++) {
            initTreeNode (&(ctree->tree.node[count]));
        }
    }
}
Example #3
0
treeNode_struct* createNode()
{
	treeNode_struct* tn=(treeNode_struct*)malloc(sizeof(treeNode_struct));
	initTreeNode(tn);
	return tn;
}