这篇教程C++ HASH_FIND_STR函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HASH_FIND_STR函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_FIND_STR函数的具体用法?C++ HASH_FIND_STR怎么用?C++ HASH_FIND_STR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HASH_FIND_STR函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: find_contextfn_context* find_context(fn_context *cx, char *name){ log_msg("COMPL", "find_context"); if (!cx || !name) { log_msg("COMPL", "not available."); return NULL; } if (cx == cxroot) cx = cxtbl; if (cx->argc > 0) { fn_context *find; HASH_FIND_STR(cx, name, find); if (find) { log_msg("COMPL", "::found %s %s", name, find->key); return find; } } fn_context_arg *find_arg; HASH_FIND_STR(cxargs, cx->key, find_arg); if (!find_arg) return NULL; fn_context *find; HASH_FIND_STR(find_arg->cx, name, find); if (!find) return NULL; return find; //TODO: else find next param}
开发者ID:Hummer12007,项目名称:nav,代码行数:32,
示例2: add_entryToSTablevoid add_entryToSTable(char *vname, char *sname, void *val, void *address, int type) { if(getExecutionFlag() == 1) { struct sym_table *s; char* hash_vn = get_vnameHash(vname); if(hash_vn != NULL) { HASH_FIND_STR(stable, hash_vn, s); } else { HASH_FIND_STR(stable, vname, s); } //HASH_FIND_STR(stable, vname, s); if (s == NULL) { s = (struct sym_table *)malloc(sizeof(struct sym_table)); s->vname = (char *)calloc((strlen(vname) + 1), sizeof(char)); strcpy(s->vname, vname); HASH_ADD_STR(stable, vname, s); } s->fval = addNewFields(sname, val, address, type); // printf("Added: %s for %s in symbol table/n", s->vname, sname); }}
开发者ID:rajshukla,项目名称:Testgen,代码行数:25,
示例3: HASH_FIND_STRstruct mod_function *get_cb(char *mod, char *cb) { Module modu = NULL; ModFunc modf = NULL; HASH_FIND_STR(mods, mod, modu); if (modu != NULL) { HASH_FIND_STR(modu->funcs, cb, modf); if (modf != NULL) { return modf; } } return NULL;};
开发者ID:asterIRC,项目名称:troutfin,代码行数:12,
示例4: del_cbint del_cb(char *mod, char *cb) { Module modu = NULL; ModFunc modf = NULL; HASH_FIND_STR(mods, mod, modu); if (modu != NULL) { HASH_FIND_STR(modu->funcs, cb, modf); if (modf != NULL) { HASH_DEL(modu->funcs, modf); free(modf); } } return 0;};
开发者ID:asterIRC,项目名称:troutfin,代码行数:13,
示例5: MPIR_T_cat_add_subcat/* Add a sub-category to an existing or new category * IN: parent_name, name of the parent category * IN: child_name, name of the child category */int MPIR_T_cat_add_subcat(const char *parent_name, const char *child_name){ int mpi_errno = MPI_SUCCESS; int parent_index, child_index; name2index_hash_t *hash_entry; cat_table_entry_t *parent; /* NULL or empty string are allowed */ if (parent_name == NULL || *parent_name == '/0' || child_name == NULL || *child_name == '/0') { goto fn_exit; } /* Find or create parent */ HASH_FIND_STR(cat_hash, parent_name, hash_entry); if (hash_entry != NULL) { /* Found parent in cat_table */ parent_index = hash_entry->idx; } else { /* parent is a new category */ MPIR_T_cat_create(parent_name); parent_index = utarray_len(cat_table) - 1; } /* Find or create child */ HASH_FIND_STR(cat_hash, child_name, hash_entry); if (hash_entry != NULL) { /* Found child in cat_table */ child_index = hash_entry->idx; } else { /* child is a new category */ MPIR_T_cat_create(child_name); child_index = utarray_len(cat_table) - 1; } /* Connect parent and child */ parent = (cat_table_entry_t *)utarray_eltptr(cat_table, parent_index); utarray_push_back(parent->subcat_indices, &child_index); /* Notify categories have been changed */ cat_stamp++;fn_exit: return mpi_errno;fn_fail: goto fn_exit;}
开发者ID:zhanglt,项目名称:mpich,代码行数:53,
示例6: mainint main(int argc,char *argv[]) { name_rec *name, *names=NULL; char linebuf[BUFLEN]; FILE *file; int i=0,j=0; if ( (file = fopen( "test14.dat", "r" )) == NULL ) { perror("can't open: "); exit(-1); } while (fgets(linebuf,BUFLEN,file) != NULL) { i++; if ( (name = (name_rec*)malloc(sizeof(name_rec))) == NULL) exit(-1); strncpy(name->boy_name,linebuf,BUFLEN); HASH_ADD_STR(names,boy_name,name); } fseek(file,0,SEEK_SET); while (fgets(linebuf,BUFLEN,file) != NULL) { HASH_FIND_STR(names,linebuf,name); if (!name) printf("failed to find: %s", linebuf); else j++; } fclose(file); printf("lookup on %d of %d names succeeded/n", j, i); return 0;}
开发者ID:Agyar,项目名称:uthash,代码行数:29,
示例7: del_vnameHashvoid del_vnameHash(char* key){ vnameHash* v; HASH_FIND_STR(vnames, key, v); if(v != NULL){ int occ; char find = '_'; const char *ptr = strrchr(v->vname_occ, find); if(ptr) { int i = strlen(v->vname_occ); int s = ptr - v->vname_occ + 1; char *occStr = (char*) malloc(sizeof(char)*(i-s+1)); strncpy(occStr, v->vname_occ + s, i-s); occ = atoi(occStr); if(occ == 0){ HASH_DEL( vnames, v); printf("Old Hash: %s/n", v->vname_occ); } else{ printf("Old Hash: %s/n", v->vname_occ); occ--; char* newVarname_occ = (char*) malloc(sizeof(char)*(s+5)); strncpy(newVarname_occ, v->vname_occ, s); char tmp[5]; sprintf(tmp,"%d",occ); strcat(newVarname_occ,tmp); HASH_DEL( vnames, v); vnameHash* vnew = (vnameHash*)malloc(sizeof(vnameHash)); strcpy(vnew->vname_occ,newVarname_occ); strcpy(vnew->vname,key); printf("New Hash: %s/n", vnew->vname_occ); HASH_ADD_STR(vnames, vname, vnew); } } }}
开发者ID:rajshukla,项目名称:Testgen,代码行数:35,
示例8: get_vnameHashchar* get_vnameHash(char* key){ vnameHash* v; HASH_FIND_STR(vnames, key, v); if(v != NULL){ return v->vname_occ; }}
开发者ID:rajshukla,项目名称:Testgen,代码行数:7,
示例9: updateARP//Update ARP entry for the srcipvoid updateARP(char *ip){ ARP_table *entry,*new_entry; ip_mac *val; if (pthread_rwlock_rdlock(&arp_lock) != 0) { printf("Can't acquire read ARP lock./n"); } HASH_FIND_STR(arp_tbl,ip,entry); pthread_rwlock_unlock(&arp_lock); if(entry == NULL) { return; } else { val = entry->value; if(val->valid) { new_entry = (ARP_table*) malloc(sizeof(ARP_table)); strcpy(new_entry->key,ip); val->timestamp = time(0); new_entry->value = val; if (pthread_rwlock_wrlock(&arp_lock) != 0) { printf("Can't acquire read ARP lock./n"); } HASH_REPLACE_STR(arp_tbl, key, entry, new_entry); pthread_rwlock_unlock(&arp_lock); } }}
开发者ID:heratgandhi,项目名称:DCN_Final_Project,代码行数:34,
示例10: roster_item_receivedroster_item_t* roster_item_received( const char* jid, const char* name, subscription_state_t sub ) { roster_item_t* i = NULL; roster_item_t* n = NULL; HASH_FIND_STR(roster, jid, i); if (!i) { NEW(n); i = n; } if (i->jid) { FREE(i->jid); } if (i->name) { FREE(i->name); } i->jid = OOM_CHECK(strdup(jid)); i->name = OOM_CHECK(strdup(name)); i->subscription = sub; if (n) { HASH_ADD_KEYPTR(hh, roster, i->jid, strlen(i->jid), i); } return i;}
开发者ID:dpc,项目名称:xmppconsole,代码行数:30,
示例11: addToIntTablevoid addToIntTable(char *sname, int *val) { struct intVartable *s; HASH_FIND_STR(itable, sname, s); if(CDG_Module==1){ if (s == NULL) { s = (struct intVartable *)malloc(sizeof(struct intVartable)); s->sname = (char *)malloc(sizeof(char) * (strlen(sname) + 1)); strcpy(s->sname, sname); HASH_ADD_STR(itable, sname, s); s->value = val; }}else { if (s == NULL) { s = (struct intVartable *)malloc(sizeof(struct intVartable)); s->sname = (char *)malloc(sizeof(char) * (strlen(sname) + 1)); strcpy(s->sname, sname); HASH_ADD_STR(itable, sname, s); s->value = val; } if(noInsertionInTables == 0) s->value = val; }//printf("Added to int table: %s val: %d/n", sname,(s->value));}
开发者ID:rajshukla,项目名称:Testgen,代码行数:35,
示例12: bucket_drop/* * drop a bucket with a specified name, * no return value, check log when you find something wrong */void bucket_drop(const char *name) { if (!is_valid_name(name)) return; struct bucket *bucket; pthread_rwlock_wrlock(&rwlock); HASH_FIND_STR(buckets, name, bucket); if (bucket) { /* TODO: find and delete all data on hard disk belongs to this bucket */ /* TODO: find and delete all request in write queue belongs to this bucket */ while (bucket->tables) { HASH_DEL(bucket->tables, bucket->tables); } HASH_DEL(buckets, bucket); } // close_storage(bucket->bsp); char link_from[1024]; snprintf(link_from, sizeof(link_from), "%s.schema", name); if (unlink(link_from) != 0) log_error("unlink %s failed: %s", link_from, strerror(errno)); snprintf(link_from, sizeof(link_from), "%s/schema", name); if (unlink(link_from) != 0) log_error("unlink %s failed: %s", link_from, strerror(errno)); pthread_rwlock_unlock(&rwlock);}
开发者ID:changjiang1124,项目名称:crabdb,代码行数:33,
示例13: initInstructionTablevoidinitInstructionTable(){ int nCount = 0; opCode *src = allOpcodes; for(int i = 0 ; i < sizeof(allOpcodes) / sizeof(opCode); i += 1, src += 1) { if (src->mne) { opCode *s = NULL; HASH_FIND_STR(InstructionTable, src->mne, s); /* s: output pointer */ if (s) { fprintf(stderr, "ERROR: instruction <%s> already in table!/n", s->mne); exit(1); } HASH_ADD_KEYPTR(hh, InstructionTable, src->mne, strlen(src->mne), src); nCount += 1; } } if (debug) fprintf(stderr, "%d opcodes added to instruction table .../n", nCount);}
开发者ID:charlesUnixPro,项目名称:dps8m,代码行数:27,
示例14: MPIR_T_cat_add_desc/* Add description to an existing or new category * IN: cat_name, name of the category * IN: cat_desc, description of the category */int MPIR_T_cat_add_desc(const char *cat_name, const char *cat_desc){ int cat_idx, mpi_errno = MPI_SUCCESS; name2index_hash_t *hash_entry; cat_table_entry_t *cat; /* NULL args are not allowed */ MPIU_Assert(cat_name); MPIU_Assert(cat_desc); HASH_FIND_STR(cat_hash, cat_name, hash_entry); if (hash_entry != NULL) { /* Found it, i.e., category already exists */ cat_idx = hash_entry->idx; cat = (cat_table_entry_t *)utarray_eltptr(cat_table, cat_idx); MPIU_Assert(cat->desc == NULL); cat->desc = MPL_strdup(cat_desc); MPIU_Assert(cat->desc); } else { /* Not found, so create a new category */ cat = MPIR_T_cat_create(cat_name); cat->desc = MPL_strdup(cat_desc); MPIU_Assert(cat->desc); /* Notify categories have been changed */ cat_stamp++; }fn_exit: return mpi_errno;fn_fail: goto fn_exit;}
开发者ID:zhanglt,项目名称:mpich,代码行数:38,
示例15: MPIR_T_cat_add_cvar/* Add a cvar to an existing or new category * IN: cat_name, name of the category * IN: cvar_index, index of the cvar as defined by MPI_T_cvar_handle_alloc() * If cat_name is NULL or a empty string, nothing happpens. */int MPIR_T_cat_add_cvar(const char *cat_name, int cvar_index){ int mpi_errno = MPI_SUCCESS; name2index_hash_t *hash_entry; cat_table_entry_t *cat; /* NULL or empty string are allowed */ if (cat_name == NULL || *cat_name == '/0') goto fn_exit; HASH_FIND_STR(cat_hash, cat_name, hash_entry); if (hash_entry != NULL) { /* Found it, i.e., category already exists */ int cat_idx = hash_entry->idx; cat = (cat_table_entry_t *)utarray_eltptr(cat_table, cat_idx); /* FIXME: Is it worth checking duplicated vars? Probably not */ utarray_push_back(cat->cvar_indices, &cvar_index); } else { /* Not found, so create a new category */ cat = MPIR_T_cat_create(cat_name); utarray_push_back(cat->cvar_indices, &cvar_index); /* Notify categories have been changed */ cat_stamp++; }fn_exit: return mpi_errno;fn_fail: goto fn_exit;}
开发者ID:zhanglt,项目名称:mpich,代码行数:37,
示例16: findRegister//Get the register codechar* findRegister(char key[]){ while(key[0] == ' ' || key[0] == '/t') key = ++key; int lastIndex = strlen(key) - 1; while(key[lastIndex] == ' ' || key[lastIndex] == '/t'){ key[lastIndex] = '/0'; lastIndex--; } struct hash *r; static char buffer[5]; HASH_FIND_STR(registers, key, r); if(r != NULL){ itoa(r->value, buffer, 2); if(strlen(buffer) < 5) strcpy(buffer, completeBinary(5, buffer)); buffer[5] = '/0'; return buffer; } return "NULL";}
开发者ID:biabsantana,项目名称:PBLSD2016,代码行数:26,
示例17: update_timervoid update_timer( char *key, double value ) { syslog(LOG_DEBUG, "update_timer ( %s, %f )/n", key, value); statsd_timer_t *t; syslog(LOG_DEBUG, "HASH_FIND_STR '%s'/n", key); HASH_FIND_STR( timers, key, t ); syslog(LOG_DEBUG, "after HASH_FIND_STR '%s'/n", key); if (t) { syslog(LOG_DEBUG, "Updating old timer entry"); wait_for_timers_lock(); utarray_push_back(t->values, &value); t->count++; remove_timers_lock(); } else { syslog(LOG_DEBUG, "Adding new timer entry"); t = malloc(sizeof(statsd_timer_t)); strcpy(t->key, key); t->count = 0; utarray_new(t->values, &timers_icd); utarray_push_back(t->values, &value); t->count++; wait_for_timers_lock(); HASH_ADD_STR( timers, key, t ); remove_timers_lock(); }}
开发者ID:ak2consulting,项目名称:statsd-c-buildpackage,代码行数:27,
示例18: update_countervoid update_counter( char *key, double value, double sample_rate ) { syslog(LOG_DEBUG, "update_counter ( %s, %f, %f )/n", key, value, sample_rate); statsd_counter_t *c; HASH_FIND_STR( counters, key, c ); if (c) { syslog(LOG_DEBUG, "Updating old counter entry"); if (sample_rate == 0) { wait_for_counters_lock(); c->value = c->value + value; remove_counters_lock(); } else { wait_for_counters_lock(); c->value = c->value + ( value * ( 1 / sample_rate ) ); remove_counters_lock(); } } else { syslog(LOG_DEBUG, "Adding new counter entry"); c = malloc(sizeof(statsd_counter_t)); strcpy(c->key, key); c->value = 0; if (sample_rate == 0) { c->value = value; } else { c->value = value * ( 1 / sample_rate ); } wait_for_counters_lock(); HASH_ADD_STR( counters, key, c ); remove_counters_lock(); }}
开发者ID:ak2consulting,项目名称:statsd-c-buildpackage,代码行数:32,
示例19: MPIR_Comm_apply_hintsint MPIR_Comm_apply_hints(MPID_Comm * comm_ptr, MPID_Info * info_ptr){ int mpi_errno = MPI_SUCCESS; MPID_Info *hint = NULL; char hint_name[MPI_MAX_INFO_KEY] = { 0 }; struct MPIR_Comm_hint_fn_elt *hint_fn = NULL; MPID_MPI_STATE_DECL(MPID_STATE_MPIR_COMM_APPLY_HINTS); MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_APPLY_HINTS); MPL_LL_FOREACH(info_ptr, hint) { /* Have we hit the default, empty info hint? */ if (hint->key == NULL) continue; strncpy(hint_name, hint->key, MPI_MAX_INFO_KEY); HASH_FIND_STR(MPID_hint_fns, hint_name, hint_fn); /* Skip hints that MPICH doesn't recognize. */ if (hint_fn) { mpi_errno = hint_fn->fn(comm_ptr, hint, hint_fn->state); if (mpi_errno) MPIR_ERR_POP(mpi_errno); } } fn_exit: MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_APPLY_HINTS); return mpi_errno; fn_fail: goto fn_exit;}
开发者ID:Niharikareddy,项目名称:mpich,代码行数:33,
示例20: dump_treestatic void dump_tree(struct node *root, int level, unsigned int nb_lines, struct node **uniq){ struct node *current; struct node *search; int should_dump; if (root == NULL) return ; HASH_SORT(root, weight_sort); for (current = root; current != NULL; current = current->hh.next) { should_dump = 1; if (level == 0) { HASH_FIND_STR(*uniq, current->word, search); should_dump = search == NULL; kick_all_uniques(current, uniq); } if (should_dump && (level > 0 || count_childs(current->childs) > 0)) { printf("%*s[%d] %s ", 4 * level, "", current->weight, current->word); dump_tree(try_flat_dump(current->childs), level + 1, nb_lines, uniq); } }}
开发者ID:JulienPalard,项目名称:Mine,代码行数:31,
示例21: open_port/* Opens a port with the driver. */static ssize_topen_port(struct pcap_drv *pcap_drv, const char *name) { pthread_rwlock_wrlock(pcap_drv->ports_rwlock); // double check the port was not created b/w the calls struct pcap_port *port; HASH_FIND_STR(pcap_drv->ports_map, name, port); if (port != NULL) { pthread_rwlock_unlock(pcap_drv->ports_rwlock); return port->id; } if (pcap_drv->ports_num >= MAX_PORTS) { logger_log(pcap_drv->logger, LOG_ERR, "Cannot open more ports."); pthread_rwlock_unlock(pcap_drv->ports_rwlock); return -1; } port = pcap_port_open(pcap_drv, pcap_drv->ports_num, name); if (port != NULL) { pcap_drv->ports[pcap_drv->ports_num] = port; pcap_drv->ports_num++; HASH_ADD_KEYPTR(hh, pcap_drv->ports_map, port->name, strlen(port->name), port); pthread_rwlock_unlock(pcap_drv->ports_rwlock); return port->id; } else { pthread_rwlock_unlock(pcap_drv->ports_rwlock); return -1; }}
开发者ID:TrafficLab,项目名称:ofss,代码行数:32,
示例22: HASH_FIND_STRconst action_t *action_get(const char *id){ action_hash_item_t *item; HASH_FIND_STR(g_actions, id, item); if (!item) LOG_W("Cannot find action %s", id); return item ? item->action : NULL;}
开发者ID:AbdelghaniDr,项目名称:goxel,代码行数:7,
示例23: pkg_manifest_keys_newintpkg_manifest_keys_new(struct pkg_manifest_key **key){ int i; struct pkg_manifest_key *k; struct dataparser *dp; if (*key != NULL) return (EPKG_OK); for (i = 0; manifest_keys[i].key != NULL; i++) { HASH_FIND_STR(*key, manifest_keys[i].key, k); if (k == NULL) { k = calloc(1, sizeof(struct pkg_manifest_key)); k->key = manifest_keys[i].key; k->type = manifest_keys[i].type; HASH_ADD_KEYPTR(hh, *key, k->key, strlen(k->key), k); } HASH_FIND_UCLT(k->parser, &manifest_keys[i].valid_type, dp); if (dp != NULL) continue; dp = calloc(1, sizeof(struct dataparser)); dp->type = manifest_keys[i].valid_type; dp->parse_data = manifest_keys[i].parse_data; HASH_ADD_UCLT(k->parser, type, dp); } return (EPKG_OK);}
开发者ID:grtodd,项目名称:pkg,代码行数:29,
示例24: indexWord/* * indexes a word, calling other functions to check and add to hashtable * returns 1 on success, otherwise it returns 0 */int indexWord( char *key, char *filename ) { if( key == NULL || filename == NULL ) { // ya dun gooffed return 0; } TokenPtr word, search; HASH_FIND_STR(words, key, search); // if the word exists in the hash table, check its fileNodes if ( search ) { // shouldn't happen in current implementation if ( search -> fileHead == NULL ) { addFileNode( search, filename ); } else if ( !strcmp(filename, (search->fileHead->filename)) ) { // file already exists for word search->fileHead->tokenCount++; } else { // file doesn't exist for word addFileNode( search, filename ); } } else { // word doesn't exist in the hashtable, create new word and file if ( (word = (TokenPtr) malloc(sizeof(struct Token))) == NULL ) exit(-1); char *newKey = (char *) malloc(sizeof(char) * strlen(key)); strcpy(newKey, key); word -> key = newKey; word -> fileHead = NULL; HASH_ADD_STR( words, key, word ); addFileNode( word, filename ); } return 1;}
开发者ID:mc4,项目名称:Systems_Programming,代码行数:34,
示例25: peer_leavevoid peer_leave(unsigned int ip, short port){ char ip_port[20]; memset(ip_port, 0, sizeof(ip_port)); char* ip_and_port_format = (char *)"%d:%d"; sprintf(ip_port, ip_and_port_format, ip, port); struct peer *s; HASH_FIND_STR(peers, ip_port, s); if(s!=NULL){ unsigned int left_room = s->room; pthread_mutex_lock(&peers_lock); HASH_DEL( peers, s); free(s); pthread_mutex_unlock(&peers_lock); pthread_mutex_lock(&stdout_lock); fprintf(stderr, "%s left %d/n", ip_port, left_room); pthread_mutex_unlock(&stdout_lock); packet pkt; pkt.header.type = 'l'; pkt.header.error = '/0'; pkt.header.payload_length = 0; struct sockaddr_in peer_addr = get_sockaddr_in(ip, port); int status = sendto(sock, &pkt, sizeof(pkt.header), 0, (struct sockaddr *)&peer_addr, sizeof(peer_addr)); if (status == -1) { pthread_mutex_lock(&stdout_lock); fprintf(stderr, "%s/n", "error - error sending packet to peer"); pthread_mutex_unlock(&stdout_lock); } peer_list(0, -1, left_room); }else{ send_error(ip, port, 'l', 'e'); }}
开发者ID:bschmaltz,项目名称:c-p2p-chat,代码行数:32,
示例26: mainint main(int argc, char*argv[]) { person_t *people=NULL, *person; const char **name; const char * names[] = { "bob", "jack", "gary", "ty", "bo", "phil", "art", "gil", "buck", "ted", NULL }; int id=0; for(name=names; *name; name++) { if ( (person = (person_t*)malloc(sizeof(person_t))) == NULL) exit(-1); strncpy(person->first_name, *name,10); person->id = id++; HASH_ADD_STR(people,first_name,person); printf("added %s (id %d)/n", person->first_name, person->id); } person=NULL; person_t **p=&person; for(name=names; *name; name++) { HASH_FIND_STR(people,*name,*p); if (person) printf("found %s (id %d)/n", person->first_name, person->id); else printf("failed to find %s/n", *name); } return 0;}
开发者ID:Agyar,项目名称:uthash,代码行数:27,
示例27: add_nodevoid add_node(struct Node *fileNode, void *token){ struct hash *h; int toAdd = 0; HASH_FIND_STR(tokenHash, token, h); if(h == NULL){ h = (struct hash*)malloc(sizeof(struct hash)); h->token = token; h->file = fileNode; h->file->count = 1; HASH_ADD_STR(tokenHash, token, h); //add this hash node to the hash table } else{ struct Node* ptr = h->file; while(ptr!= NULL){ //finding the file here so we can increment its count if(fileNode->fileName == ptr->fileName){ h->file->count++; toAdd = 1; //this file exists in the hash and we just incremented the counter break; }else{ ptr = ptr->next; } } if(toAdd == 0){ ptr = fileNode; ptr->count++; ptr->next = h->file; h->file = ptr; //making the pointer the head of the linked list } }}
开发者ID:T-G-P,项目名称:SearchMeCapn,代码行数:30,
示例28: checkInARPTable//Check whether IP address exists in the ARP tablechar* checkInARPTable(char *ip){ ARP_table *entry; ip_mac *val; if (pthread_rwlock_rdlock(&arp_lock) != 0) { printf("Can't acquire read ARP lock./n"); } HASH_FIND_STR(arp_tbl,ip,entry); pthread_rwlock_unlock(&arp_lock); if(entry == NULL) { return NULL; } else { val = entry->value; if(val->valid) { if(debugging) printf("Cached: %s/n",val->mac); return val->mac; } else { return NULL; } }}
开发者ID:heratgandhi,项目名称:DCN_Final_Project,代码行数:31,
示例29: pkg_jobs_update_conflict_priorityvoidpkg_jobs_update_conflict_priority(struct pkg_jobs_universe *universe, struct pkg_solved *req){ struct pkg_conflict *c = NULL; struct pkg *lp = req->items[1]->pkg; struct pkg_job_universe_item *found, *cur, *rit = NULL; while (pkg_conflicts(lp, &c) == EPKG_OK) { rit = NULL; HASH_FIND_STR(universe->items, c->uid, found); assert(found != NULL); LL_FOREACH(found, cur) { if (cur->pkg->type != PKG_INSTALLED) { rit = cur; break; } } assert(rit != NULL); if (rit->priority >= req->items[1]->priority) { pkg_jobs_update_universe_item_priority(universe, req->items[1], rit->priority + 1, PKG_PRIORITY_UPDATE_CONFLICT); /* * Update priorities for a remote part as well */ pkg_jobs_update_universe_item_priority(universe, req->items[0], req->items[0]->priority, PKG_PRIORITY_UPDATE_REQUEST); } }}
开发者ID:HardenedBSD,项目名称:pkg,代码行数:32,
示例30: update_timervoid update_timer(char *key, double value){ DPRINTF("update_timer ( %s, %f )/n", key, value); statsd_timer_t *t; DPRINTF("HASH_FIND_STR '%s'/n", key); HASH_FIND_STR( timers, key, t ); DPRINTF("after HASH_FIND_STR '%s'/n", key); if (t) { DPRINTF("Updating old timer entry/n"); utarray_push_back(t->values, &value); t->count++; } else { DPRINTF("Adding new timer entry/n"); t = malloc(sizeof(statsd_timer_t)); strcpy(t->key, key); t->count = 0; utarray_new(t->values, &timers_icd); utarray_push_back(t->values, &value); t->count++; HASH_ADD_STR( timers, key, t ); }}
开发者ID:togga,项目名称:statsd-c,代码行数:27,
注:本文中的HASH_FIND_STR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ HASH_ID函数代码示例 C++ HASH_FIND_PTR函数代码示例 |