当前位置: 首页>>代码示例>>C++>>正文


C++ HASH_FIND_STR函数代码示例

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


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


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