• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HASH_FIND_STR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: find_context

fn_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,代码来源:compl.c


示例2: 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,代码来源:symbolicExec.c


示例3: HASH_FIND_STR

struct 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,代码来源:module.c


示例4: del_cb

int 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,代码来源:module.c


示例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,代码来源:mpit.c


示例6: 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,代码来源:test14.c


示例7: 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,代码来源:helperNew.c


示例8: get_vnameHash

char* get_vnameHash(char* key){
	vnameHash* v;
        HASH_FIND_STR(vnames, key, v);
        if(v != NULL){
        	return v->vname_occ;
        }
}
开发者ID:rajshukla,项目名称:Testgen,代码行数:7,代码来源:helperNew.c


示例9: updateARP

//Update ARP entry for the srcip
void 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,代码来源:arp.c


示例10: roster_item_received

roster_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,代码来源:roster.c


示例11: 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,代码来源:updateIntegerValues.c


示例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,代码来源:bucket.c


示例13: initInstructionTable

void
initInstructionTable()
{
    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,代码来源:opcodeTable.c


示例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,代码来源:mpit.c


示例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,代码来源:mpit.c


示例16: findRegister

//Get the register code
char* 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,代码来源:Assembler.c


示例17: 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,代码来源:statsd.c


示例18: 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,代码来源:statsd.c


示例19: MPIR_Comm_apply_hints

int 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,代码来源:commutil.c


示例20: dump_tree

static 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,代码来源:dump.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HASH_ID函数代码示例发布时间:2022-05-30
下一篇:
C++ HASH_FIND_PTR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap