本文整理汇总了C++中cache_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ cache_lookup函数的具体用法?C++ cache_lookup怎么用?C++ cache_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_lookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gss_OID_loc_to_sap
/*
* When the local GSS-API library returns a single OID to the caller,
* this gss_OID is assumed to be a pointer to stable storage, and need
* not be freed by the caller. We cannot return this structure directly
* to the caller, since it is in the incorrect ABI. (Neither can we
* modify that stable storage directly, as it would break internal users
* of the OID, violate the hosts alignment expectations, attempt a write
* to immutable storage, or other bad things.) We must return a translated
* copy instead. However, to retain the "caller does not free" property,
* we must cache the values we hand out, and only ever allocate one OID
* structure in the SAP ABI for any given OID.
*
* Returns 0 on success, and errno on failure.
*/
static int
gss_OID_loc_to_sap(gss_OID loc, sapgss_OID *sap)
{
sapgss_OID s;
int code;
if (sap == NULL)
return 0;
if (loc == NULL) {
*sap = NULL;
return 0;
}
/* Try to find a cached copy to use. */
s = cache_lookup(loc);
if (s != NULL) {
*sap = s;
return 0;
} /* else */
/* Try to insert it into the cache. Success here means that the next
* lookup will succeed. */
code = cache_insert(loc);
if (code != 0) {
*sap = NULL;
return code;
}
*sap = cache_lookup(loc);
return 0;
}
开发者ID:Aribaaa,项目名称:osxsnc,代码行数:44,代码来源:sncgss.c
示例2: cache_add
struct cacheinfo *
cache_add(char *uri)
{
int fd, bytes;
int len;
struct cacheinfo *entry;
struct stat stat;
char *cur;
char header_buf[MAX_HEADER_LEN];
int header_len;
int rc;
char *rc_ptr;
int trace_fd = 0;
PRINT_TIME(NOFD, &tnow, &tprev, "cache_add: entered ");
num_cache_add_calls++;
if ((entry = cache_lookup(uri)) != 0) {
num_cache_hits++;
PRINT_TIME(NOFD, &tnow, &tprev, "cache_add: entry found - returning");
return (entry);
} else {
PRINT_TIME(NOFD, &tnow, &tprev, "cache_add: entry not found ");
}
if (cur_entry < CACHE_MAX) {
TRACE(EVT_OPEN_FILE, trace_fd = 0; rc = open(uri, O_RDONLY););
开发者ID:iscmu2012,项目名称:WebServerEval,代码行数:28,代码来源:cache_simple.c
示例3: set_schema
static void
set_schema (GConfSource *source,
const gchar *key,
const gchar *schema_key,
GError **err)
{
XMLSource* xs = (XMLSource*)source;
Dir* dir;
gchar* parent;
g_return_if_fail (source != NULL);
g_return_if_fail (key != NULL);
parent = gconf_key_directory (key);
g_assert (parent != NULL);
dir = cache_lookup (xs->cache, parent, TRUE, err);
g_free (parent);
parent = NULL;
if (dir == NULL)
return; /* error should be set */
else
{
const gchar* relative_key;
relative_key = gconf_key_key (key);
dir_set_schema (dir, relative_key, schema_key, err);
}
}
开发者ID:DOICHE,项目名称:gconf,代码行数:34,代码来源:xml-backend.c
示例4: cache_sym
static inline void cache_sym (zbar_image_scanner_t *iscn,
zbar_symbol_t *sym)
{
if(iscn->enable_cache) {
zbar_symbol_t *entry = cache_lookup(iscn, sym);
if(!entry) {
/* FIXME reuse sym */
entry = _zbar_image_scanner_alloc_sym(iscn, sym->type,
sym->datalen + 1);
memcpy(entry->data, sym->data, sym->datalen);
entry->time = sym->time - CACHE_HYSTERESIS;
entry->cache_count = -CACHE_CONSISTENCY;
/* add to cache */
entry->next = iscn->cache;
iscn->cache = entry;
}
/* consistency check and hysteresis */
uint32_t age = sym->time - entry->time;
entry->time = sym->time;
int near_thresh = (age < CACHE_PROXIMITY);
int far_thresh = (age >= CACHE_HYSTERESIS);
int dup = (entry->cache_count >= 0);
if((!dup && !near_thresh) || far_thresh)
entry->cache_count = -CACHE_CONSISTENCY;
else if(dup || near_thresh)
entry->cache_count++;
sym->cache_count = entry->cache_count;
}
else
sym->cache_count = 0;
}
开发者ID:mrdeveloperdude,项目名称:OctoMY,代码行数:33,代码来源:img_scanner.c
示例5: gconf_log
static void
unset_value (GConfSource* source,
const gchar* key,
const gchar* locale,
GError** err)
{
XMLSource* xs = (XMLSource*)source;
Dir* dir;
gchar* parent;
gconf_log(GCL_DEBUG, "XML backend: unset value `%s'", key);
parent = gconf_key_directory(key);
dir = cache_lookup(xs->cache, parent, FALSE, err);
g_free(parent);
if (dir == NULL)
return;
else
{
const gchar* relative_key;
relative_key = gconf_key_key(key);
dir_unset_value(dir, relative_key, locale, err);
}
}
开发者ID:DOICHE,项目名称:gconf,代码行数:29,代码来源:xml-backend.c
示例6: cache_sync
static GSList*
all_subdirs (GConfSource* source,
const gchar* key,
GError** err)
{
Dir* dir;
XMLSource* xs = (XMLSource*)source;
GError *sync_err;
/* We have to sync before we can do this, to see which
* subdirs have gone away.
*/
sync_err = NULL;
cache_sync (xs->cache, &sync_err);
if (sync_err)
{
gconf_log (GCL_WARNING, _("Error syncing the XML backend directory cache: %s"),
sync_err->message);
g_error_free (sync_err);
sync_err = NULL;
/* continue, may as well try our best. */
}
dir = cache_lookup (xs->cache, key, FALSE, err);
if (dir == NULL)
return NULL;
else
return dir_all_subdirs (dir, err);
}
开发者ID:DOICHE,项目名称:gconf,代码行数:30,代码来源:xml-backend.c
示例7: set_value
static void
set_value (GConfSource* source, const gchar* key, const GConfValue* value,
GError** err)
{
XMLSource* xs = (XMLSource*)source;
Dir* dir;
gchar* parent;
g_return_if_fail(value != NULL);
g_return_if_fail(source != NULL);
parent = gconf_key_directory(key);
g_assert(parent != NULL);
dir = cache_lookup(xs->cache, parent, TRUE, err);
g_free(parent);
parent = NULL;
if (dir == NULL)
{
g_return_if_fail((err == NULL || *err != NULL));
return;
}
else
{
const gchar* relative_key;
relative_key = gconf_key_key(key);
dir_set_value(dir, relative_key, value, err);
}
}
开发者ID:DOICHE,项目名称:gconf,代码行数:34,代码来源:xml-backend.c
示例8: query_metainfo
static GConfMetaInfo*
query_metainfo (GConfSource* source, const gchar* key,
GError** err)
{
XMLSource* xs = (XMLSource*)source;
gchar* parent;
Dir* dir;
parent = gconf_key_directory(key);
if (parent != NULL)
{
dir = cache_lookup(xs->cache, parent, FALSE, err);
g_free(parent);
parent = NULL;
if (dir != NULL)
{
const gchar* relative_key;
relative_key = gconf_key_key (key);
return dir_get_metainfo (dir, relative_key, err);
}
}
/* No metainfo found */
return NULL;
}
开发者ID:DOICHE,项目名称:gconf,代码行数:29,代码来源:xml-backend.c
示例9: fuse_vncache_lookup
int
fuse_vncache_lookup(vnode_t dvp, vnode_t *vpp, struct componentname *cnp)
{
#if M_OSXFUSE_ENABLE_BIG_LOCK
/*
* Make sure that biglock is actually held by the thread calling us before
* trying to unlock it. fuse_vncache_lookup is called by notification
* handlers that do not hold biglock. Trying to unlock it in this case would
* result in a kernel panic.
*/
struct fuse_data *data = fuse_get_mpdata(vnode_mount(dvp));
bool biglock_locked = fuse_biglock_have_lock(data->biglock);
if (biglock_locked) {
fuse_biglock_unlock(data->biglock);
}
#endif /* M_OSXFUSE_ENABLE_BIG_LOCK */
int ret = cache_lookup(dvp, vpp, cnp);
#if M_OSXFUSE_ENABLE_BIG_LOCK
if (biglock_locked) {
fuse_biglock_lock(data->biglock);
}
#endif
#if FUSE_TRACE_VNCACHE
IOLog("osxfuse: cache lookup ret=%d, dvp=%p, *vpp=%p, %s\n",
ret, dvp, *vpp, cnp->cn_nameptr);
#endif
return ret;
}
开发者ID:MeetLima,项目名称:osxfuse-kext,代码行数:31,代码来源:fuse_node.c
示例10: update_block_list
int
update_block_list(char *addr, int err_level)
{
size_t addr_len = strlen(addr);
if (cache_key_exist(block_list, addr, addr_len)) {
int *count = NULL;
cache_lookup(block_list, addr, addr_len, &count);
if (count != NULL) {
if (*count > MAX_TRIES)
return 1;
(*count) += err_level;
}
} else if (err_level > 0) {
int *count = (int *)ss_malloc(sizeof(int));
*count = 1;
cache_insert(block_list, addr, addr_len, count);
#ifdef __linux__
if (mode != NO_FIREWALL_MODE)
set_firewall_rule(addr, 1);
#endif
}
return 0;
}
开发者ID:ss-plus,项目名称:shadowsocksR-libev,代码行数:25,代码来源:acl.c
示例11: cache_add_packet
void cache_add_packet(struct sr_instance * sr, uint8_t * packet, unsigned int length, char * interface, struct in_addr ip) {
struct in_addr dest_ip = next_hop_ip(sr, ip);
struct sr_arp_record *record = cache_lookup(sr, dest_ip);
if(record == NULL) {
// Check to see if there is an outstanding ARP request
struct sr_arp_request *request = cache_lookup_outstanding(sr, dest_ip);
if(request == NULL) {
// Create a new ARP request
if(arp_request(sr, dest_ip, interface) == 0) {
request = cache_add_request(sr, dest_ip);
// Add the recieved message to the outstanding arp request
cache_add_message(request, packet, length, interface, ip);
} /* endif: arp request sent succesfully */
else {
printf("ARP request failed for address %s - dropping packet.\n", inet_ntoa(ip));
} /* endelse: arp request not sent succesfully */
} /* endif: no outstanding ARP request */
else {
cache_add_message(request, packet, length, interface, ip);
} /* endelse: ARP request already outstanding for this ip */
} /* endif: No record */
else {
// Send packet
struct sr_ethernet_hdr *eth_hdr = (struct sr_ethernet_hdr *)packet;
memcpy(eth_hdr->ether_dhost, record->address, ETHER_ADDR_LEN);
sr_send_packet(sr, packet, length, interface);
} /* endelse: ARP record already exists */
}
开发者ID:tprynn,项目名称:cs425-router,代码行数:34,代码来源:sr_cache.c
示例12: lookup_name_from_8_3
/*
try to find a 8.3 name in the cache, and if found then
replace the string with the original long name.
*/
static bool lookup_name_from_8_3(TALLOC_CTX *ctx,
const char *name,
char **pp_out, /* talloced on the given context. */
const struct share_params *p)
{
unsigned int hash, multiplier;
unsigned int i;
char *prefix;
char extension[4];
*pp_out = NULL;
/* make sure that this is a mangled name from this cache */
if (!is_mangled(name, p)) {
M_DEBUG(10,("lookup_name_from_8_3: %s -> not mangled\n", name));
return False;
}
/* we need to extract the hash from the 8.3 name */
hash = base_reverse[(unsigned char)name[7]];
for (multiplier=36, i=5;i>=mangle_prefix;i--) {
unsigned int v = base_reverse[(unsigned char)name[i]];
hash += multiplier * v;
multiplier *= 36;
}
/* now look in the prefix cache for that hash */
prefix = cache_lookup(ctx, hash);
if (!prefix) {
M_DEBUG(10,("lookup_name_from_8_3: %s -> %08X -> not found\n",
name, hash));
return False;
}
/* we found it - construct the full name */
if (name[8] == '.') {
strncpy(extension, name+9, 3);
extension[3] = 0;
} else {
extension[0] = 0;
}
if (extension[0]) {
M_DEBUG(10,("lookup_name_from_8_3: %s -> %s.%s\n",
name, prefix, extension));
*pp_out = talloc_asprintf(ctx, "%s.%s", prefix, extension);
} else {
M_DEBUG(10,("lookup_name_from_8_3: %s -> %s\n", name, prefix));
*pp_out = talloc_strdup(ctx, prefix);
}
TALLOC_FREE(prefix);
if (!*pp_out) {
M_DEBUG(0,("talloc_fail"));
return False;
}
return True;
}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:64,代码来源:mangle_hash2.c
示例13: cache_insert
/* Insert one entry into the cache */
int cache_insert(char *key, SPDMessageType msgtype, FT_Wave * fwave)
{
GHashTable *cache;
TCacheEntry *entry;
TCounterEntry *centry;
char *key_table;
if (FestivalCacheOn == 0)
return 0;
if (key == NULL)
return -1;
if (fwave == NULL)
return -1;
/* Check if the entry isn't present already */
if (cache_lookup(key, msgtype, 0) != NULL)
return 0;
key_table = cache_gen_key(msgtype);
log_msg(OTTS_LOG_DEBUG,
"Cache: Inserting wave with key:'%s' into table '%s'", key,
key_table);
/* Clean less used cache entries if the size would exceed max. size */
if ((FestivalCache.size + fwave->num_samples * sizeof(short))
> (FestivalCacheMaxKBytes * 1024))
if (cache_clean(fwave->num_samples * sizeof(short)) != 0)
return -1;
/* Select the right table according to language, voice, etc. or create a new one */
cache = g_hash_table_lookup(FestivalCache.caches, key_table);
if (cache == NULL) {
cache = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(FestivalCache.caches, key_table, cache);
} else {
g_free(key_table);
}
/* Fill the CounterEntry structure that will later allow us to remove
the less used entries from cache */
centry = (TCounterEntry *) g_malloc(sizeof(TCounterEntry));
centry->start = time(NULL);
centry->count = 1;
centry->size = fwave->num_samples * sizeof(short);
centry->p_caches = cache;
centry->key = g_strdup(key);
FestivalCache.cache_counter =
g_list_append(FestivalCache.cache_counter, centry);
entry = (TCacheEntry *) g_malloc(sizeof(TCacheEntry));
entry->p_counter_entry = centry;
entry->fwave = fwave;
FestivalCache.size += centry->size;
g_hash_table_insert(cache, g_strdup(key), entry);
return 0;
}
开发者ID:razr,项目名称:opentts,代码行数:61,代码来源:festival.c
示例14: do_cache_set
void do_cache_set(void) {
struct string *key = string_create();
read_into_string(key);
struct cache_entry *entry = cache_lookup(key);
if (entry == NULL) {
// There's no existing entry for this key. Find a free slot to put
// a new entry in.
entry = find_free_slot();
}
if (entry == NULL) {
// No free slots, tell the client the cache is full :-(
write(STDOUT_FILENO, &kCacheFull, sizeof(kCacheFull));
return;
}
write(STDOUT_FILENO, &kFound, sizeof(kFound));
entry->key = key;
if (entry->value == NULL) {
entry->value = string_create();
}
read_into_string(entry->value);
entry->lifetime = read_int();
}
开发者ID:Holyshatots,项目名称:Code-Everyday,代码行数:28,代码来源:fancy_cache.c
示例15: file_data_read_compressed
unsigned char *
file_data_read_compressed(struct file *file, long long offset, int size, int size_uncomp)
{
void *ret;
char *buffer = 0;
uLongf destLen=size_uncomp;
if (file->cache) {
struct file_cache_id id={offset,size,file->name_id,1};
ret=cache_lookup(file_cache,&id);
if (ret)
return ret;
ret=cache_insert_new(file_cache,&id,size_uncomp);
} else
ret=g_malloc(size_uncomp);
lseek(file->fd, offset, SEEK_SET);
buffer = (char *)g_malloc(size);
if (read(file->fd, buffer, size) != size) {
g_free(ret);
ret=NULL;
} else {
if (uncompress_int(ret, &destLen, (Bytef *)buffer, size) != Z_OK) {
dbg(0,"uncompress failed\n");
g_free(ret);
ret=NULL;
}
}
g_free(buffer);
return ret;
}
开发者ID:albertz,项目名称:navit,代码行数:32,代码来源:file.c
示例16: cache_lookup
static struct node *cache_get(const char *path)
{
struct node *node = cache_lookup(path);
if (node == NULL) {
char *pathcopy = g_strdup(path);
node = g_new0(struct node, 1);
g_hash_table_insert(cache.table, pathcopy, node);
}
开发者ID:mbouaziz,项目名称:xcurlftpfs,代码行数:8,代码来源:cache.c
示例17: cache_lookup
char *uhost_cache_lookup(const char *nick)
{
uhost_cache_entry_t *cache;
cache = cache_lookup(nick);
if (cache) return(cache->uhost);
return(NULL);
}
开发者ID:Cloudxtreme,项目名称:eggdrop-1.9,代码行数:8,代码来源:uhost_cache.c
示例18: client_recv_cb
static void
client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags) {
struct server_context *server = container_of(handle, struct server_context, udp);
if (nread > 0) {
char key[KEY_BYTES + 1] = {0};
crypto_generickey((uint8_t *)key, sizeof(key) -1, (uint8_t*)addr, sizeof(*addr), NULL, 0);
struct client_context *client = NULL;
uv_mutex_lock(&mutex);
cache_lookup(cache, key, (void *)&client);
uv_mutex_unlock(&mutex);
if (client == NULL) {
client = new_client();
client->addr = *addr;
client->local_handle = handle;
memcpy(client->key, key, sizeof(key));
uv_timer_init(handle->loop, client->timer);
uv_udp_init(handle->loop, &client->server_handle);
client->server_handle.data = client;
uv_udp_recv_start(&client->server_handle, server_alloc_cb, server_recv_cb);
uv_mutex_lock(&mutex);
cache_insert(cache, client->key, (void *)client);
uv_mutex_unlock(&mutex);
}
int clen = nread + PRIMITIVE_BYTES + addrlen;
int mlen = nread + addrlen;
uint8_t *c = (uint8_t *)buf->base - PRIMITIVE_BYTES - addrlen;
uint8_t *m = (uint8_t *)buf->base - addrlen;
if (server->dest_addr->sa_family == AF_INET) {
struct sockaddr_in *addr = (struct sockaddr_in *)server->dest_addr;
m[0] = 1;
memcpy(m + 1, &addr->sin_addr, 4);
memcpy(m + 1 + 4, &addr->sin_port, 2);
} else {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)server->dest_addr;
m[0] = 4;
memcpy(m + 1, &addr->sin6_addr, 16);
memcpy(m + 1 + 16, &addr->sin6_port, 2);
}
int rc = crypto_encrypt(c, m, mlen);
if (!rc) {
reset_timer(client);
forward_to_server(server->server_addr, client, c, clen);
}
} else {
goto error;
}
return;
error:
free(buf->base - addrlen - PRIMITIVE_BYTES);
}
开发者ID:sinme,项目名称:xsocks-1,代码行数:58,代码来源:xforwarder_udprelay.c
示例19: do_server_request
static void
do_server_request(struct server *sv, int connfd)
{
int ret;
struct request *rq;
struct file_data *data;
data = file_data_init();
rq = request_init(connfd, data);
if (!rq) {
file_data_free(data);
return;
}
if(cache_active ==1){
pthread_mutex_lock( &conditionMutex);
struct hash_node *cache_stored;
cache_stored= cache_lookup(data->file_name);
if(cache_stored!=NULL){ // check if it populated in the cache{
data->file_buf = Malloc(cache_stored->data->file_size);
strncpy(data->file_buf, cache_stored->data->file_buf, cache_stored->data->file_size);
data->file_size =cache_stored->data->file_size;
}
else{
/* reads file,
* fills data->file_buf with the file contents,
* data->file_size with file size. */
pthread_mutex_unlock( &conditionMutex );
ret = request_readfile(rq);
pthread_mutex_lock( &conditionMutex );
// need to renew the cache
if(data->file_size<max_cache){
if(data->file_size <=(max_cache-cache_current_size) ){
cache_insert(data);
}
else{
cache_evict(data->file_size);
cache_insert(data);
}
}
}
pthread_mutex_unlock( &conditionMutex );
}
else{
ret = request_readfile(rq);
if (!ret)
goto out;
}
/* sends file to client */
request_sendfile(rq);
out:
request_destroy(rq);
file_data_free(data);
}
开发者ID:miki2112,项目名称:multi_threaded_web_server,代码行数:57,代码来源:server_thread.c
示例20: gst_vaapi_display_cache_lookup_by_name
/**
* gst_vaapi_display_cache_lookup_by_name:
* @cache: the #GstVaapiDisplayCache
* @display_name: the display name to match
*
* Looks up the display cache for the specified display name.
*
* Return value: a #GstVaapiDisplayInfo matching @display_name, or
* %NULL if none was found
*/
const GstVaapiDisplayInfo *
gst_vaapi_display_cache_lookup_by_name (GstVaapiDisplayCache * cache,
const gchar * display_name, guint display_types)
{
g_return_val_if_fail (cache != NULL, NULL);
return cache_lookup (cache, compare_display_name, display_name,
display_types);
}
开发者ID:GStreamer,项目名称:gstreamer-vaapi,代码行数:19,代码来源:gstvaapidisplaycache.c
注:本文中的cache_lookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论