void CacheRelease( void ) /******************************* * Called at any time we want to invalidate the cache */ { #ifdef USE_DIR_CACHE #ifdef CACHE_STATS if( Glob.cachestat ) { PrtMsg( INF | CACHERELEASE ); } #endif freeDirectList( cacheHead ); cacheHead = NULL; MemShrink(); CACHE_DELAY_RELEASE(); #endif }
static void x_ipc_msgFreeMsg(MSG_PTR msg) { LIST_PTR hndList; if (msg) { if (msg->direct == -1) return; msg->direct = -1; /* Flag that msg has already been freed */ if ((msg)->hndList != NULL) { hndList = (msg)->hndList; (msg)->hndList = NULL; x_ipc_listFree(&hndList); } freeDirectList(msg); if (msg->msgData) { x_ipcFree((char *)msg->msgData->name); x_ipc_freeFormatter(&(msg->msgData->msgFormat)); x_ipc_freeFormatter(&(msg->msgData->resFormat)); x_ipcFree((char *)msg->msgData); } x_ipcFree((char *)(msg)); msg = NULL; } }
STATIC enum cacheRet cacheDir( DHEADPTR *pdhead, char *path ) /************************************************************ * Given a full pathname or just a path ending in \ cache all the files * in that directory. Assumes that this directory is not already * cached. Does not link into list off cacheHead. */ { CENTRYPTR cnew; /* new cacheEntry struct */ DIR *parent; /* parent directory entry */ DIR *entry; /* current directory entry */ HASH_T h; /* hash value */ size_t len; #ifdef CACHE_STATS UINT32 bytes = 0; /* counter */ UINT32 files = 0; /* counter */ UINT32 hits = 0; /* counter */ if( Glob.cachestat ) { PrtMsg( INF | CACHING_DIRECTORY, path ); } #endif *pdhead = myMalloc( sizeof( **pdhead ) ); if( *pdhead == NULL ) { return( CACHE_NOT_ENUF_MEM ); } #ifdef CACHE_STATS bytes += sizeof( **pdhead ); #endif /* clear the memory */ _fmemset( *pdhead, 0, sizeof( **pdhead ) ); len = strlen( path ); _fmemcpy( (*pdhead)->dh_name, path, len + 1 ); strcpy( &path[len], "*.*" ); parent = opendir( path ); if( parent == NULL ) { #ifdef CACHE_STATS if( Glob.cachestat ) { PrtMsg( INF | NEOL | CACHE_FILES_BYTES, files, bytes, hits ); } #endif return( CACHE_OK ); /* an empty, or nonexistent directory */ } entry = readdir( parent ); while( entry != NULL ) { if( !(entry->d_attr & IGNORE_MASK) ) { /* we tromp on entry, and get hash value */ h = Hash( FixName( entry->d_name ), HASH_PRIME ); cnew = myMalloc( sizeof( *cnew ) ); if( cnew == NULL ) { freeDirectList( *pdhead ); /* roll back, and abort */ *pdhead = NULL; #ifdef CACHE_STATS if( Glob.cachestat ) { if( hits % 8 != 0 ) { PrtMsg( INF | NEWLINE ); } PrtMsg( INF | CACHE_MEM ); } #endif return( CACHE_NOT_ENUF_MEM ); } #ifdef CACHE_STATS bytes += sizeof( *cnew ); ++files; #endif cnew->ce_tt = _DOSStampToTime( entry->d_date, entry->d_time ); ConstMemCpy( cnew->ce_name, entry->d_name, NAME_MAX + 1 ); cnew->ce_next = (*pdhead)->dh_table[h]; (*pdhead)->dh_table[h] = cnew; #ifdef CACHE_STATS if( Glob.cachestat && cnew->ce_next != NULL ) { ++hits; PrtMsg( INF | ((hits % 8 == 0) ? 0 : NEOL) | HIT_ON_HASH, h ); } #endif } entry = readdir( parent ); } closedir( parent ); #ifdef CACHE_STATS if( Glob.cachestat ) { if( hits % 8 != 0 ) { PrtMsg( INF | NEWLINE ); } PrtMsg( INF | CACHE_FILES_BYTES, files, bytes, hits ); } #endif return( CACHE_OK ); }