NSAPI_PUBLIC cache_entry_t * cache_insert(cache_t *cache, void *key, void *data, cache_entry_functions_t *fn) { cache_entry_t *newentry; SOLARIS_PROBE(cache_insert_start, "cache"); NS_ASSERT(cache_crit); NS_ASSERT(cache); #ifdef CACHE_DEBUG NS_ASSERT(cache->magic == CACHE_MAGIC); #endif if ( (newentry = cache_create_entry()) == NULL) { ereport(LOG_FAILURE, XP_GetAdminStr(DBT_cacheInsertUnableToCreateCacheEn_)); SOLARIS_PROBE(cache_insert_end, "cache"); return NULL; } if ( cache_insert_p(cache, newentry, key, data, fn) < 0) { PERM_FREE(newentry); SOLARIS_PROBE(cache_insert_end, "cache"); return NULL; } SOLARIS_PROBE(cache_insert_end, "cache"); return newentry; }
/* if the entry doesn't exist then create it and return it. otherwise just return it */ cache_entry* find_or_create_cache_entry(int tname) { cache_entry * entry; if((entry=find_in_cache(tname))) return entry; else return cache_create_entry(tname); }