这篇教程C++ tfind函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tfind函数的典型用法代码示例。如果您正苦于以下问题:C++ tfind函数的具体用法?C++ tfind怎么用?C++ tfind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tfind函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: afscp_GetStatusintafscp_GetStatus(const struct afscp_venusfid *fid, struct AFSFetchStatus *s){ struct afscp_volume *v; struct afscp_server *server; struct AFSCallBack cb; struct AFSVolSync vs; struct AFSFid tf = fid->fid; struct afscp_statent *stored, key; void *cached; int code, i, j; time_t now; v = afscp_VolumeById(fid->cell, fid->fid.Volume); if (v == NULL) { return -1; } memset(&key, 0, sizeof(key)); memcpy(&key.me, fid, sizeof(*fid)); cached = tfind(&key, &v->statcache, statcompare); if (cached != NULL) { stored = *(struct afscp_statent **)cached; pthread_mutex_lock(&(stored->mtx)); memmove(s, &stored->status, sizeof(*s)); afs_dprintf(("Stat %u.%lu.%lu.%lu returning cached result/n", fid->cell->id, fid->fid.Volume, fid->fid.Vnode, fid->fid.Unique)); if (stored->nwaiters) pthread_cond_broadcast(&(stored->cv)); pthread_mutex_unlock(&(stored->mtx)); return 0; } code = ENOENT; for (i = 0; i < v->nservers; i++) { server = afscp_ServerByIndex(v->servers[i]); if (server && server->naddrs > 0) { for (j = 0; j < server->naddrs; j++) { time(&now); code = RXAFS_FetchStatus(server->conns[j], &tf, s, &cb, &vs); if (code == 0) { afscp_AddCallBack(server, &fid->fid, s, &cb, now); /* calls _StatStuff */ afs_dprintf(("Stat %d.%lu.%lu.%lu" " ok: type %ld size %ld/n", fid->cell->id, afs_printable_uint32_lu(fid->fid.Volume), afs_printable_uint32_lu(fid->fid.Vnode), afs_printable_uint32_lu(fid->fid.Unique), afs_printable_int32_ld(s->FileType), afs_printable_int32_ld(s->Length))); return 0; } } } } afscp_errno = code; return -1;}
开发者ID:sanchit-matta,项目名称:openafs,代码行数:59,
示例2: sp_rtrace_tracker_query_symbolchar* sp_rtrace_tracker_query_symbol(sp_rtrace_tracker_t* tracker, const char* name){ char* demangled_name = (char*)cplus_demangle(name, DMGL_ANSI | DMGL_PARAMS); if (!tfind(demangled_name ? demangled_name : name, &tracker->symbols, (int (*)(const void *, const void *))_strcmpp)) { return NULL; } return demangled_name ? demangled_name : strdup(name);}
开发者ID:mer-tools,项目名称:sp-rtrace,代码行数:8,
示例3: tfindDfsFile *findFile(char *path){ if (!path[0] || !strcmp(path, "/")) return root; DfsFile **fh = tfind(path, &pathRoot, file_compare); return fh ? *fh : NULL;}
开发者ID:bwhite,项目名称:dfs,代码行数:8,
示例4: assert/* find existing service queue */struct tpservice *fnd_service(char *svcname){ assert(svcname); debug(1, "fnd_service(%.*s)", XATMI_SERVICE_NAME_LENGTH, svcname); struct tpservice **svc = tfind(svcname, &services, cmp_service); debug(2, "fnd_service(%.*s) -> 0x%x", XATMI_SERVICE_NAME_LENGTH, svcname, svc ? *svc : 0); return svc ? *svc : 0;}
开发者ID:openhoodie,项目名称:hoodie,代码行数:9,
示例5: __pmUnpinPDUBufint__pmUnpinPDUBuf(void *handle){ bufctl_t *pcp, pcp_search; void *bcp; assert(((__psint_t)handle % sizeof(int)) == 0); PM_INIT_LOCKS(); PM_LOCK(__pmLock_libpcp); /* * Initialize a dummy bufctl_t to use only as search key; * only its bc_buf & bc_size fields need to be set, as that's * all that bufctl_t_compare will look at. */ pcp_search.bc_buf = handle; pcp_search.bc_size = 1; bcp = tfind(&pcp_search, &buf_tree, &bufctl_t_compare); /* * NB: don't release the lock until final disposition of this object; * we don't want to play TOCTOU. */ if (likely(bcp != NULL)) { pcp = *(bufctl_t **)bcp; } else {#ifdef PCP_DEBUG if (pmDebug & DBG_TRACE_PDUBUF) { fprintf(stderr, "__pmUnpinPDUBuf(" PRINTF_P_PFX "%p) -> fails/n", handle); pdubufdump(); }#endif PM_UNLOCK(__pmLock_libpcp); return 0; }#ifdef PCP_DEBUG if (unlikely(pmDebug & DBG_TRACE_PDUBUF)) fprintf(stderr, "__pmUnpinPDUBuf(" PRINTF_P_PFX "%p) -> pdubuf=" PRINTF_P_PFX "%p, pincnt=%d/n", handle, pcp->bc_buf, pcp->bc_pincnt - 1);#endif assert((&pcp->bc_buf[0] <= (char*)handle) && ((char*)handle < &pcp->bc_buf[pcp->bc_size])); if (likely(--pcp->bc_pincnt == 0)) { tdelete(pcp, &buf_tree, &bufctl_t_compare); PM_UNLOCK(__pmLock_libpcp); free(pcp); } else { PM_UNLOCK(__pmLock_libpcp); } return 1;}
开发者ID:ColeJackes,项目名称:pcp,代码行数:58,
示例6: cps_containsintcps_contains( pid_t pid){ return root == NULL ? 0 : tfind(&pid, &root, compare) != NULL;}
开发者ID:KeithLatteri,项目名称:awips2,代码行数:9,
示例7: find_object// return true only if the device and inode information has not been added beforestatic inline int find_object(struct stat *st){ struct dev_and_inode obj; void *res; obj.dev = st->st_dev; obj.ino = st->st_ino; res = (void *) tfind(&obj, &seen_inodes, compare_func); return res != (void *) NULL;}
开发者ID:INL,项目名称:BlackLab,代码行数:10,
示例8: dict_findnode_t* dict_find(struct dict* d, uint64_t k){ dictPair* p = malloc(sizeof(dictPair)); p->key = k; dictPair* r = (dictPair*) tfind(p, &d->root, compar); if (r == NULL) return NULL; else return (*(dictPair **)r)->value;}
开发者ID:yaps8,项目名称:griso,代码行数:9,
示例9: vlc_internalsstatic variable_t *Lookup( vlc_object_t *obj, const char *psz_name ){ vlc_object_internals_t *priv = vlc_internals( obj ); variable_t **pp_var; vlc_mutex_lock(&priv->var_lock); pp_var = tfind( &psz_name, &priv->var_root, varcmp ); return (pp_var != NULL) ? *pp_var : NULL;}
开发者ID:chouquette,项目名称:vlc,代码行数:9,
示例10: h_get_token_type_numberHTokenType h_get_token_type_number(const char* name) { Entry e; e.name = name; Entry **ret = (Entry**)tfind(&e, &tt_registry, compare_entries); if (ret == NULL) return 0; else return (*ret)->value;}
开发者ID:abiggerhammer,项目名称:hammer,代码行数:9,
示例11: cometd_find_subscriptionstatic cometd_client_subscription* cometd_find_subscription(cometd_client_t * client, const char * channel) { if (!client || !channel) return 0; cometd_client_impl* cli = (cometd_client_impl*)client; cometd_client_subscription test; test.channel = channel; void ** found = tfind(&test, &cli->subscriptions, &compare_subs); return found ? *(cometd_client_subscription**)found : 0;}
开发者ID:GhostGumm,项目名称:C_To_iOS_framework,代码行数:9,
示例12: tfind/** Internal use only. */static dictionary_entry_t *dictionary_tfind(dictionary_t *d, const char *key){ dictionary_entry_t tentry = {key, NULL}; void *tresult = tfind((void *)&tentry, &d->root, compare); if (tresult == NULL) return NULL; else return *((dictionary_entry_t **)tresult);}
开发者ID:mrvicadai,项目名称:CS241-SimpleServer,代码行数:11,
示例13: metafield_searchmetafield_t* metafield_search(const char * name){ metafield_t **metafield, search; if (!name) return NULL; search.name = name; metafield = tfind(&search, &metafields_root, (ELEMENT_COMPARE) metafield_compare); return metafield ? *metafield : NULL;}
开发者ID:dotysan,项目名称:paris-traceroute.libparistraceroute,代码行数:10,
示例14: tfinddatastore_entry_t *dictionary_tfind(datastore_t *ds, const char *key){ datastore_entry_t tentry = {key, NULL, 0}; void *tresult = tfind((void *)&tentry, &ds->root, compare); if (tresult == NULL) return NULL; else return *((datastore_entry_t **)tresult);}
开发者ID:Yankkk,项目名称:C,代码行数:10,
示例15: algorithm_searchalgorithm_t * algorithm_search(const char * name){ algorithm_t ** algorithm, search; if (!name) return NULL; search.name = name; algorithm = tfind(&search, &algorithms_root, (ELEMENT_COMPARE) algorithm_compare); return algorithm ? *algorithm : NULL;}
开发者ID:dotysan,项目名称:paris-traceroute.libparistraceroute,代码行数:10,
示例16: prog_pts_tree_entry_found// Returns 1 if the proper function name of cur_entry is found in// prog_pts_tree and 0 otherwise. Always look for cur_entry->fjalar_name.Bool prog_pts_tree_entry_found(FunctionEntry* cur_entry) { if (tfind((void*)cur_entry->fjalar_name, (void**)&prog_pts_tree, compareStrings)) { return 1; } else { return 0; }}
开发者ID:barkinet,项目名称:daikon-javascript-output,代码行数:13,
示例17: Cache_Get_Common_Dir/* Look in caches, 0=found and valid, 1=not or uncachable in the first place */static enum cache_task_return Cache_Get_Common_Dir(struct dirblob *db, time_t * duration, const struct tree_node *tn){ enum cache_task_return ctr_ret; time_t now = NOW_TIME; size_t size; struct tree_opaque *opaque; LEVEL_DEBUG("Get from cache sn " SNformat " pointer=%p extension=%d", SNvar(tn->tk.sn), tn->tk.p, tn->tk.extension); CACHE_RLOCK; opaque = tfind(tn, &cache.temporary_tree_new, tree_compare) ; if ( opaque == NULL ) { // not found in new tree if ( cache.time_retired + duration[0] > now ) { // old tree could be new enough opaque = tfind(tn, &cache.temporary_tree_old, tree_compare) ; } } if ( opaque != NULL ) { duration[0] = opaque->key->expires - now ; if (duration[0] >= 0) { LEVEL_DEBUG("Dir found in cache"); size = opaque->key->dsize; if (DirblobRecreate(TREE_DATA(opaque->key), size, db) == 0) { //printf("Cache: snlist=%p, devices=%lu, size=%lu/n",*snlist,devices[0],size) ; ctr_ret = ctr_ok; } else { ctr_ret = ctr_size_mismatch; } } else { //char b[26]; //printf("GOT DEAD now:%s",ctime_r(&now,b)) ; //printf(" then:%s",ctime_r(&opaque->key->expires,b)) ; LEVEL_DEBUG("Dir expired in cache"); ctr_ret = ctr_expired; } } else { LEVEL_DEBUG("Dir not found in cache"); ctr_ret = ctr_not_found; } CACHE_RUNLOCK; return ctr_ret;}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:42,
示例18: RemoveSource/** * Removes a source (if present) by index. */static void RemoveSource (services_discovery_t *sd, uint32_t idx){ services_discovery_sys_t *sys = sd->p_sys; struct device **dp = tfind (&idx, &sys->root, cmpsrc); if (dp == NULL) return; struct device *d = *dp; tdelete (d, &sys->root, cmpsrc); DestroySource (d);}
开发者ID:4udak,项目名称:vlc,代码行数:15,
示例19: utimFindAsciiByUnit/* * Returns the unit-and-identifier whose ASCII identifier corresponding to a * unit. * * Arguments: * map The unit-to-identifier map. * unit The unit to be used as the key in the search. * Returns: * NULL The map doesn't contain an entry corresponding to "unit" whose * identifier is in ASCII. * else Pointer to the entry corresponding to "unit" whose identifier is * in ASCII. */static UnitAndId*utimFindAsciiByUnit( UnitToIdMap* const map, const ut_unit* const unit){ UnitAndId targetEntry; UnitAndId** treeEntry; targetEntry.unit = (ut_unit*)unit; treeEntry = tfind(&targetEntry, &map->ascii, compareUnits); return treeEntry == NULL ? NULL : *treeEntry;}
开发者ID:rsignell-usgs,项目名称:UDUNITS-2,代码行数:26,
示例20: Cache_Del_Alias_Persistent/* look in persistent alias->sn tree */static void Cache_Del_Alias_Persistent( struct alias_tree_node * atn){ struct tree_opaque *opaque; struct alias_tree_node *atn_found = NULL; PERSISTENT_RLOCK; opaque = tfind(atn, &cache.persistent_alias_tree, alias_tree_compare) ; if ( opaque != NULL ) { atn_found = (struct alias_tree_node *) (opaque->key); } PERSISTENT_RUNLOCK; owfree(atn_found) ;}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:14,
示例21: RemoveDevice/** * Removes a udev device (if present). */static void RemoveDevice (services_discovery_t *sd, struct udev_device *dev){ services_discovery_sys_t *p_sys = sd->p_sys; dev_t num = udev_device_get_devnum (dev); struct device **dp = tfind (&(dev_t){ num }, &p_sys->root, cmpdev); if (dp == NULL) return; struct device *d = *dp; tdelete (d, &p_sys->root, cmpdev); DestroyDevice (d);}
开发者ID:etix,项目名称:vlc,代码行数:16,
示例22: xtreeFindxtreePos_t xtreeFind(void *treehandle, char *key){ xtree_t *tree = treehandle; treerec_t **result, rec; if (!tree) return NULL; rec.key = key; rec.userdata = NULL; rec.compare = tree->compare; result = tfind(&rec, &tree->root, xtree_i_compare); return (result ? *result : NULL);}
开发者ID:Kotty666,项目名称:xymon,代码行数:14,
示例23: grdx_scgi_get_headerchar * grdx_scgi_get_header(const char * __name, const scgi_t * __scgi){ struct header_s _header_key; void * _tfind_ret; _header_key.name = __name; _header_key.value = NULL; _tfind_ret = tfind(&_header_key, &(__scgi->tree_header), compare_header); if(_tfind_ret == NULL) { return NULL; } return (*((struct header_s**)_tfind_ret))->value;}
开发者ID:Giraudux,项目名称:libgiraudux,代码行数:14,
示例24: inhx32_tree_input/* * Stage 1: Input * * filename should either be `-' for `stdin' else an accessible * disk file. */uint32_tinhx32_tree_input(void **root, const char *filename, uint32_t *count){ FILE *fp = stdin; uint32_t nbytes = 0; void *entry; pic_data *data; *count = 0; /* Open file or stdin */ if (strcmp(filename, "-") && (fp = fopen(filename, "rb")) == NULL) { printf("%s: error: fopen failed [%s] [%s]/n", __func__, filename, strerror(errno)); return 0; /* Empty */ } /* While not EOF, process data */ while ((data = inhx32_get(fp)) != NULL) { /* Detect duplicate data in tree */ entry = tfind((void *)data, root, inhx32_tree_compare); if (entry != NULL) { printf("%s: fatal error: duplicate address [%08X]/n", __func__, data->address); io_exit(EX_SOFTWARE); /* Panic */ } /* Add new data to tree */ entry = tsearch((void *)data, root, inhx32_tree_compare); if (entry == NULL) { printf("%s: fatal error: tsearch failed/n", __func__); io_exit(EX_OSERR); /* Panic */ } /* Update counters */ (*count)++; nbytes += data->nbytes; } /* Close file or stdin */ if (strcmp(filename, "-")) fclose(fp); /* Information */ if (nbytes == 0) printf("%s: information: no valid input data/n", __func__); /* Return number of bytes */ return nbytes;}
开发者ID:GBert,项目名称:openwrt-files,代码行数:56,
示例25: cps_remove/** * Ensures that a PID doesn't exist. * * @param pid [in] The PID to not exist. */voidcps_remove( pid_t pid){ void *node = tfind(&pid, &root, compare); if (node != NULL) { pid_t *elt = *(pid_t**)node; (void)tdelete(&pid, &root, compare); free(elt); count--; }}
开发者ID:Unidata,项目名称:LDM,代码行数:19,
示例26: delStringint delString(struct StringTable *st, const char *key){ struct StringTableNode *result; char *toFree; result = (struct StringTableNode *) tfind(&key, &st->stringTableNodeTab, compare); if (result == NULL) return ERR_NOSTRING; result = * (struct StringTableNode **) result; toFree = result->key; tdelete(result, &st->stringTableNodeTab, compare); free(toFree); free(result); return 0;}
开发者ID:BCI-AR,项目名称:NeuroServer,代码行数:14,
示例27: iol_del_eventintiol_del_event(int fd){ struct ioloop_event_desc tmpdesc = {.iol_fd = fd}; struct epoll_event tmpev; struct epoll_event **ev = NULL; tmpev.data.ptr = &tmpdesc; ev = tfind(&tmpev, &_iol_manager.root, _iol_cmp); if(ev){ return _iol_del_internal_event(fd, *ev); } return -1;}
开发者ID:7za,项目名称:divers,代码行数:15,
示例28: Cache_Get_Alias_Commonstatic INDEX_OR_ERROR Cache_Get_Alias_Common( struct alias_tree_node * atn){ INDEX_OR_ERROR bus = INDEX_BAD; time_t now = NOW_TIME; struct tree_opaque *opaque; CACHE_RLOCK; opaque = tfind(atn, &cache.temporary_alias_tree_new, alias_tree_compare) ; if ( opaque == NULL ) { // try old tree opaque = tfind(atn, &cache.temporary_alias_tree_old, alias_tree_compare) ; } if ( opaque != NULL ) { // test expiration if ( ((struct alias_tree_node *)(opaque->key))->expires > now) { bus = ((struct alias_tree_node *)(opaque->key))->bus ; LEVEL_DEBUG("Found %s on bus.%d",ALIAS_TREE_DATA(atn),bus) ; } } CACHE_RUNLOCK; LEVEL_DEBUG("Finding %s unsuccessful",ALIAS_TREE_DATA(atn)) ; owfree(atn) ; return bus;}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:24,
示例29: strdupstatic struct perf_apm *find_or_add_perf(const char *name){ struct perf_apm perf, *ret; perf.name = strdup(name); ret = tfind(&perf, &root, compare); free(perf.name); if (!ret) { ret = new_perf(name); } else { ret = *((void **)ret); } return ret;}
开发者ID:jberaud,项目名称:lttng2lxt,代码行数:15,
示例30: Cache_Del_Commonstatic GOOD_OR_BAD Cache_Del_Common(const struct tree_node *tn){ struct tree_opaque *opaque; time_t now = NOW_TIME; GOOD_OR_BAD ret = gbBAD; LEVEL_DEBUG("Delete from cache sn " SNformat " in=%p index=%d", SNvar(tn->tk.sn), tn->tk.p, tn->tk.extension); CACHE_WLOCK; opaque = tfind(tn, &cache.temporary_tree_new, tree_compare) ; if ( opaque == NULL ) { // not in new tree if ( cache.time_to_kill > now ) { // old tree still alive opaque = tfind(tn, &cache.temporary_tree_old, tree_compare) ; } } if ( opaque != NULL ) { opaque->key->expires = now - 1; ret = gbGOOD; } CACHE_WUNLOCK; return ret;}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:24,
注:本文中的tfind函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tfp_sprintf函数代码示例 C++ tf_has函数代码示例 |