您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ HASH_ADD_STR函数代码示例

51自学网 2021-06-01 21:22:22
  C++
这篇教程C++ HASH_ADD_STR函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中HASH_ADD_STR函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_ADD_STR函数的具体用法?C++ HASH_ADD_STR怎么用?C++ HASH_ADD_STR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了HASH_ADD_STR函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: addToIntTable

void 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,


示例2: tree_insert_model

void tree_insert_model( const char* name, 												const char* prototype,												av_interface_t interface,												const char* parent_name ){	assert(name);	  if( _tree == NULL ) // i.e. nothing in the tree yet		{			// set up the root node for the sim itself			bzero(&_root,sizeof(_root));			strncpy(_root.id,"sim",strlen("sim"));			strncpy(_root.prototype, _root.id, strlen(_root.id));			_root.interface = AV_INTERFACE_SIM;			utarray_new( _root.children, &ut_str_icd ); // initialize string array 						_av_node_t* rootp = &_root; // macro needs a pointer arg			HASH_ADD_STR( _tree, id, rootp );	 }    assert( name && strlen(name) < NAME_LEN_MAX );   assert( parent_name == NULL || strlen(parent_name) < NAME_LEN_MAX );     // insert this new node into the tree    _av_node_t *node = malloc( sizeof(_av_node_t));  assert(node);  bzero(node,sizeof(_av_node_t));    strncpy(node->id,name,NAME_LEN_MAX);	node->interface = interface;	strncpy( node->prototype, prototype, strlen(prototype));  utarray_new( node->children, &ut_str_icd ); // initialize string array     // add the node to the tree, keyed on the name    HASH_ADD_STR( _tree, id, node );    // did something happen?  assert( _tree != NULL );    // add the child to the parent    _av_node_t *parent_node = NULL;    if( parent_name )	 HASH_FIND_STR( _tree, parent_name, parent_node );  else		parent_node = &_root;  assert( parent_node );    utarray_push_back( parent_node->children, &name );}
开发者ID:AutonomyLab,项目名称:avon,代码行数:52,


示例3: InitStoplistConfig

void InitStoplistConfig(){  char *stoplist_path = Config("STOPLIST");  if (stoplist_path == NULL) {    return;  }  FILE *fp = fopen(stoplist_path, "rb");  if (fp == NULL) {    fprintf(stderr, "Unable to load stoplist: %s/n", stoplist_path);    return;  }  char term[TERM_MAX_LEN+1];  for (;;) {    if (fscanf(fp, "%s/n", term) < 1) break;    strToLower(term);    Stem(term);    Stopword *newStopword;    HASH_FIND_STR(stoplist, term, newStopword);    if (newStopword == NULL) {      newStopword = malloc(sizeof(Stopword));      strcpy(newStopword->t, term);      HASH_ADD_STR(stoplist, t, newStopword);    }  }  fclose(fp);}
开发者ID:tachappell,项目名称:topsig,代码行数:28,


示例4: tokenset_add

int tokenset_add( struct tokenset *p, char *n ){   struct _token *s;   HASH_FIND_STR( p->tokens, n, s );   if ( !_IS_NULL( s ) )      return s->id;   s = ( struct _token * ) malloc( sizeof ( struct _token ) );   s->text = malloc( ( 1 + strlen( n ) ) * sizeof ( char ) );   strcpy( s->text, n );   s->id = p->count;#if 0   HASH_ADD_STR( p->tokens, text, s );#else   HASH_ADD_KEYPTR( hh, p->tokens, s->text, strlen( s->text ), s );#endif   p->count += 1;                                /* ready to map next entry */   return s->id;}
开发者ID:crowja,项目名称:constats,代码行数:25,


示例5: add_hash_entry

// internal function to insert a pair to the hash tablestatic void add_hash_entry(const char* function_name, funcPointerT fpt){  ns_t * s;  s =malloc (sizeof(ns_t));  if (!s)  {    printf("Fatal error: add_hash_entry() malloc() for s failed!/n");    assert(0);  }#if 0  if ((s->func_name=malloc(strlen(function_name)+1)) == NULL)  {    printf("Fatal error: add_hash_entry() malloc() for s->func_name failed!/n");    assert(0);  }  else#endif      {    strcpy(s->func_name, function_name);    s->fp = fpt;//    HASH_ADD_INT(entries, func_name,s);    HASH_ADD_STR(entries, func_name,s);  }}
开发者ID:8l,项目名称:rose,代码行数:26,


示例6: fillSizes

int fillSizes(char *sizes)/** * Fills the hash table of chrom sizes * * * */{  struct lineFile *lf;  lf = lineFileOpen(sizes,TRUE);  char *line;  struct sizes_hash *s;  while(lineFileNextReal(lf,&line)){    char *split[2];    chopByWhite(line,split,2);    s = malloc(sizeof(struct sizes_hash));    strcpy(s->name, split[0]);    s->length = atoi(split[1]);    int i;    for(i=0;i<NUMSAMPLES;i++)      s->numHets[i] = 0;    HASH_ADD_STR(chrSizes,name,s);  }  return 0;}
开发者ID:git-cambridge,项目名称:KentLib,代码行数:25,


示例7: 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,


示例8: update_timer

void 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,


示例9: main

int main(int argc,char *argv[]){    name_rec *name, *names=NULL;    char linebuf[BUFLEN];    FILE *file;    file = fopen( "test11.dat", "r" );    if (file == NULL) {        perror("can't open: ");        exit(-1);    }    while (fgets(linebuf,BUFLEN,file) != NULL) {        name = (name_rec*)malloc(sizeof(name_rec));        if (name == NULL) {            exit(-1);        }        strcpy(name->boy_name, linebuf);        HASH_ADD_STR(names,boy_name,name);    }    fclose(file);    HASH_SORT(names,namecmp);    for(name=names; name!=NULL; name=(name_rec*)(name->hh.next)) {        printf("%s",name->boy_name);    }    return 0;}
开发者ID:RamJett,项目名称:uthash,代码行数:29,


示例10: main

int 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,


示例11: main

int 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,


示例12: del_vnameHash

void 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,


示例13: MPIR_Comm_register_hint

int MPIR_Comm_register_hint(const char *hint_key, MPIR_Comm_hint_fn_t fn, void *state){    int mpi_errno = MPI_SUCCESS;    struct MPIR_Comm_hint_fn_elt *hint_elt = NULL;    MPID_MPI_STATE_DECL(MPID_STATE_MPIR_COMM_REGISTER_HINT);    MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_REGISTER_HINT);    if (MPID_hint_fns == NULL) {        MPIR_Add_finalize(free_hint_handles, NULL, MPIR_FINALIZE_CALLBACK_PRIO - 1);    }    hint_elt = MPIU_Malloc(sizeof(struct MPIR_Comm_hint_fn_elt));    strncpy(hint_elt->name, hint_key, MPI_MAX_INFO_KEY);    hint_elt->state = state;    hint_elt->fn = fn;    HASH_ADD_STR(MPID_hint_fns, name, hint_elt);  fn_exit:    MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_REGISTER_HINT);    return mpi_errno;  fn_fail:    goto fn_exit;}
开发者ID:Niharikareddy,项目名称:mpich,代码行数:25,


示例14: main

int main(int argc,char *argv[]){    name_rec *name, *names=NULL;    char linebuf[BUFLEN];    FILE *file;    int i=0;    if (argc != 2) {        fprintf(stderr,"usage: %s file/n", argv[0]);        exit(-1);    }    if ( (file = fopen( argv[1], "r" )) == NULL ) {        perror("can't open: ");        exit(-1);    }    while (fgets(linebuf,BUFLEN,file) != NULL) {        name = (name_rec*)malloc(sizeof(name_rec));        if (name == NULL) {            exit(-1);        }        strcpy(name->boy_name, linebuf);        HASH_ADD_STR(names,boy_name,name);        i++;    }    fprintf(stderr,"%d keys emitted./n", i);    fclose(file);    return 0;}
开发者ID:RamJett,项目名称:uthash,代码行数:31,


示例15: add_node

void 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,


示例16: update_timer

void 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,


示例17: update_counter

void 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,


示例18: add_entryToSTable

void 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,


示例19: init_known_metrics

/* Initialize htable with the metrics known by the system */int init_known_metrics(){  /* Initialize PAPI library */  int retval;  retval = PAPI_library_init(PAPI_VER_CURRENT);  if (retval != PAPI_VER_CURRENT) {    fprintf(stderr, "Error! PAPI_library_init %d/n",retval);    PAPI_shutdown();  }  /* Initialize custom metrics storage */  HASH_CLEAR(hh, callbacks_storage);  for(int i = 0; i < available_metrics_no; ++i) {    htable *new_pair = NULL;    new_pair = malloc(sizeof(htable));    if (!new_pair) {        fprintf(stderr, "can't alloc memory for the new pair/n");        exit(-1);    }    strcpy(new_pair->key, callbacks[i].alias);    new_pair->value = callbacks[i].func;    /* insert the new pair in callbacks_storage */    HASH_ADD_STR(callbacks_storage, key, new_pair);  }  return 0;}
开发者ID:GeorgianaElena,项目名称:Monitoring_clarisse,代码行数:34,


示例20: hash_add_queue_kv

/* * 函 数:hash_add_queue_kv * 功 能:hash表中添加新的险 */mq_queue_t* hash_add_queue_kv(const char* qname, mq_queue_t* queue){    int qname_len = 0;    mq_queue_list_t* tmp_queue = NULL;    qname_len = strlen(qname);    if (qname_len < 0)    {        log_warn("Add hash fail, Invalid key");        return false;    }    tmp_queue = (mq_queue_list_t*)malloc(sizeof(mq_queue_list_t));    if (tmp_queue == NULL)    {        log_warn("Add hash fail, errno[%d], error msg[%s]", errno, strerror(errno));        return false;    }    memset(tmp_queue, '/0', sizeof(mq_queue_list_t));    /* Key setvar */    memcpy(tmp_queue->qname, qname, strlen(qname));    /* Value setvar */    memcpy(&(tmp_queue->mq_queue), queue, sizeof(mq_queue_t));    /* Qname: name of key field */    HASH_ADD_STR(g_mq_qlist, qname, tmp_queue);    return &tmp_queue->mq_queue;}
开发者ID:bigtreetree,项目名称:ucmq,代码行数:32,


示例21: add_signal

void add_signal(struct frame_struct *db, int frameId, char *signalName, int startBit, int signalLength, int is_big_endian, int signedState, float factor, float offset, float min, float max, char *unit, char *receiverList, unsigned char isMultiplexer, unsigned char muxId){	struct frame_struct *frame;	struct signal_struct *newSignal;	frame = find_frame(db, frameId);		newSignal = malloc(sizeof(struct signal_struct));	strcpy(newSignal->name, signalName);	newSignal->startBit = startBit;	newSignal->signalLength = signalLength;	newSignal->is_big_endian = is_big_endian;	newSignal->is_signed = signedState;	newSignal->factor = factor;	newSignal->offset = offset;	newSignal->min = min;	newSignal->max = max;                        if(isMultiplexer > 0)        {            frame->isMultiplexed = 1;        }        newSignal->isMultiplexer = isMultiplexer;        newSignal->muxId = muxId;		strcpy(newSignal->unit, unit);	strcpy(newSignal->receiverList, receiverList);	HASH_ADD_STR( frame->signals, name, newSignal );}
开发者ID:ebroecker,项目名称:SocketCandecodeSignals,代码行数:31,


示例22: addToDict

Entry addToDict(Dict d, int et, char *key, ...) {  va_list ap;  va_start(ap, key);  Entry entry = (Entry)malloc(sizeof(struct entry));  strncpy(entry->key, key, sizeof(entry->key));  char *sval;  char ival;  char dval;  switch(et) {    case echar:      sval = va_arg(ap, char *);      strncpy(entry->value.str, sval, sizeof(entry->key));      break;    case eint:      ival = va_arg(ap, int);      entry->value.num = ival;      break;    case edouble:      dval = va_arg(ap, double);      entry->value.dub = dval;      break;  }  HASH_ADD_STR(d->entries, key, entry);  return entry;}
开发者ID:jrbalsano,项目名称:knode-language,代码行数:25,


示例23: add_vnameHash

void add_vnameHash(char* key, char* value) {    vnameHash* v;    HASH_FIND_STR(vnames, key, v);    if(v==NULL){	v = (vnameHash*)malloc(sizeof(vnameHash));	strcpy(v->vname_occ,value);	strcpy(v->vname,key);        HASH_ADD_STR(vnames, vname, v);    }    else{    	HASH_DEL( vnames, v);    	v = (vnameHash*)malloc(sizeof(vnameHash));	strcpy(v->vname_occ,value);	strcpy(v->vname,key);        HASH_ADD_STR(vnames, vname, v);    }}
开发者ID:rajshukla,项目名称:Testgen,代码行数:17,


示例24: augroup_add

void augroup_add(char *key){  log_msg("HOOK", "GROUP ADD");  Augroup *aug = malloc(sizeof(Augroup));  aug->key = strdup(key);  augroup_remove(key);  HASH_ADD_STR(aug_tbl, key, aug);}
开发者ID:jollywho,项目名称:nav,代码行数:9,


示例25: _swUnitTest_setup

void _swUnitTest_setup(swUnitTest_Func func, char *func_name, int run_times){	swHashTable_unitTst *u;	u = (swHashTable_unitTst *) malloc(sizeof(swHashTable_unitTst));	u->key = func_name;	u->func = func;	u->run_times = run_times;	HASH_ADD_STR(unitTest_ht, key, u);}
开发者ID:899,项目名称:swoole,代码行数:9,


示例26: addURL

/* * This adds the URL to the RestAPI hashmap */void addURL(char *url, struct Response (*restFunc)()) {	struct RestAPI *tmp = malloc(sizeof(struct RestAPI));	tmp->restUrl = url;	tmp->func = restFunc;	HASH_ADD_STR(router, restUrl, tmp);	printf("Added Route: %s/n", url);}
开发者ID:sanket28,项目名称:URL-Router-C,代码行数:12,


示例27: main

int main(int argc, char **argv){  if (argc < 5) {    fprintf(stderr, "usage: {input sigfile} {output sigfile} {document ids to filter} {0=exclude 1=include}/n");    return 0;  }  FILE *fi;  FILE *fo;  FILE *fids;  if ((fi = fopen(argv[1], "rb"))) {    if ((fo = fopen(argv[2], "wb"))) {      fids = fopen(argv[3], "rb");      for (;;) {        char docname[256];        if (fscanf(fids, "%[^/n]/n", docname) < 1) break;        filt *f = malloc(sizeof(filt));        strcpy(f->docname, docname);        HASH_ADD_STR(filterhash, docname, f);      }      int do_filter = atoi(argv[4]);      readSigHeader(fi);      rewind(fi);      unsigned char *fileheader_buffer = malloc(cfg.headersize);      fread(fileheader_buffer, 1, cfg.headersize, fi);      fwrite(fileheader_buffer, 1, cfg.headersize, fo);      free(fileheader_buffer);      unsigned char *sigheader_buffer = malloc(cfg.sig_offset);      unsigned char *sig_buffer = malloc(cfg.sig_width / 8);      for (;;) {        if (fread(sigheader_buffer, 1, cfg.sig_offset, fi) == 0) break;        fread(sig_buffer, 1, cfg.sig_width / 8, fi);        filt *f;        HASH_FIND_STR(filterhash, (char *)sigheader_buffer, f);        int exclude = f == NULL ? 1 : 0;        int include = f == NULL ? 0 : 1;        if (do_filter ? exclude : include) {          fwrite(sigheader_buffer, 1, cfg.sig_offset, fo);          fwrite(sig_buffer, 1, cfg.sig_width / 8, fo);        }      }      free(sigheader_buffer);      free(sig_buffer);      fclose(fids);      fclose(fo);    } else {      fprintf(stderr, "Unable to open output file/n");    }    fclose(fi);  } else {    fprintf(stderr, "Unable to open input file/n");  }  return 0;}
开发者ID:tachappell,项目名称:topsig,代码行数:57,


示例28: compl_add

static void compl_add(char *fmt_compl, fn_context **parent){  log_msg("COMPL", "compl_add");  log_msg("COMPL", "%s", fmt_compl);  int pidx = 0;  int grpc = count_subgrps(fmt_compl, ";");  if (grpc < 1) {    log_msg("COMPL", "invalid format");    return;  }  char *line = strdup(fmt_compl);  fn_context *cx = malloc(sizeof(fn_context));  fn_context **args = malloc(grpc*sizeof(fn_context*));  char *keyptr;  char *saveptr;  char *lhs = strtok_r(line, ";", &saveptr);  fn_context *find;  keyptr = strdup(lhs);  char *param = strtok_r(NULL, ";", &saveptr);  for (pidx = 0; pidx < grpc; pidx++) {    if (compl_param(&args[pidx], param) == -1)      goto breakout;    param = strtok_r(NULL, ";", &saveptr);  }  find = NULL;  cx->key = keyptr;  cx->argc = grpc;  cx->params = args;  cx->cmpl = NULL;  HASH_FIND_STR(*parent, keyptr, find);  if (find) {    log_msg("COMPL", "ERROR: context already defined");    goto breakout;  }  else {    log_msg("*|*", "%s %s %s", cx->key, args[0]->key, keyptr);    HASH_ADD_STR(*parent, key, cx);  }  free(line);  return;breakout:  log_msg("**", "CLEANUP");  for (pidx = pidx - 1; pidx > 0; pidx--) {    free(args[pidx]);  }  free(cx);  free(args);  free(line);  return;}
开发者ID:Hummer12007,项目名称:nav,代码行数:57,


示例29: load_seqid_taxid_rel

void load_seqid_taxid_rel(char * seqid_taxid_file){    seqid_taxid_rel = NULL;    tax_to_seqs = NULL;    gzFile seq_tax = gzopen(seqid_taxid_file, "r");    kseq_t * seq_t = kseq_init(seq_tax);    struct seqid_taxid_single * tstr;    struct taxid_seqid * tts;    int l = 0;        while ((l = kseq_read(seq_t)) >= 0) {        //add taxid related to seqid        uint64_t tmp_taxid = 0;        HASH_FIND_STR(seqid_taxid_rel, seq_t->name.s, tstr);        if (tstr == NULL) {            if (seq_t->name.l > SEQID_SIZE) {                printf("seqid %s is too long, must be less than 100 characters.  Exiting...", seq_t->name.s);                exit(1);            }            tstr = (struct seqid_taxid_single *)malloc(sizeof(struct seqid_taxid_single));            memset(tstr->seqid, '/0', SEQID_SIZE*sizeof(char));            strncpy(tstr->seqid, seq_t->name.s, seq_t->name.l);            tmp_taxid = strtoull(seq_t->seq.s, NULL, 10);            tstr->taxid = tmp_taxid;            HASH_ADD_STR(seqid_taxid_rel, seqid, tstr);                    }        else {            printf("%s already seen in hash",seq_t->name.s);        }                //add seqid(s) related to taxid        HASH_FIND(hh, tax_to_seqs, &tmp_taxid, sizeof(uint64_t), tts);        if (tts == NULL) {            tts = (struct taxid_seqid *)malloc(sizeof(struct taxid_seqid));            tts->taxid = tmp_taxid;            tts->num_seqids = 0;            tts->max_seqs = 10;            tts->seqids = (char **)malloc(sizeof(char *)*10);            tts->seqids[tts->num_seqids] = (char *)calloc(SEQID_SIZE,sizeof(char));            strncpy(tts->seqids[tts->num_seqids], seq_t->name.s, seq_t->name.l);            tts->num_seqids++;            HASH_ADD(hh, tax_to_seqs, taxid, sizeof(uint64_t), tts);        }        else {            if (tts->num_seqids >= tts->max_seqs) {                tts->max_seqs = 2 * tts->max_seqs;                tts->seqids = (char **)realloc(tts->seqids, sizeof(char *)*tts->max_seqs);            }            tts->seqids[tts->num_seqids] = (char *)calloc(SEQID_SIZE,sizeof(char));            strncpy(tts->seqids[tts->num_seqids], seq_t->name.s, seq_t->name.l);            tts->num_seqids++;        }    }    gzclose(seq_tax);}
开发者ID:NoSeatbelts,项目名称:taxonomer_0.5,代码行数:55,


示例30: InitPYSplitData

void InitPYSplitData(FcitxPinyinConfig* pyconfig){    size_t size = sizeof(pySplitData) / sizeof(pySplitData[0]);    int i = 0;    for (i = 0; i < size; i ++) {        PYMappedSplitData* data = fcitx_utils_malloc0(sizeof(PYMappedSplitData));        sprintf(data->py, "%s %s", pySplitData[i].py1, pySplitData[i].py2);        data->freq = pySplitData[i].freq;        HASH_ADD_STR(pyconfig->splitData, py, data);    }}
开发者ID:niubenben,项目名称:fcitx,代码行数:11,



注:本文中的HASH_ADD_STR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ HASH_COUNT函数代码示例
C++ HASH_ADD_KEYPTR函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。