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


C++ dict_new函数代码示例

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


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

示例1: cli_cmd_uuid_reset_cbk

int
cli_cmd_uuid_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
                        const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        int                     sent = 0;
        int                     parse_error = 0;
        gf_answer_t             answer = GF_ANSWER_NO;
        char                    *question = NULL;
        cli_local_t             *local = NULL;
        dict_t                  *dict  = NULL;
        xlator_t                *this  = NULL;

        question = "Resetting uuid changes the uuid of local glusterd. "
                   "Do you want to continue?";

        if (wordcount != 3) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UUID_RESET];

        this = THIS;
        frame = create_frame (this, this->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict) {
                ret = -1;
                goto out;
        }
        CLI_LOCAL_INIT (local, words, frame, dict);
        answer = cli_cmd_get_confirmation (state, question);

        if (GF_ANSWER_NO == answer) {
                ret = 0;
                goto out;
        }

        //send NULL as argument since no dictionary is sent to glusterd
        if (proc->fn) {
                ret = proc->fn (frame, this, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("uuid reset failed");
        }

        CLI_STACK_DESTROY (frame);

        return ret;
}
开发者ID:lkzhd,项目名称:glusterfs-annotation,代码行数:60,代码来源:cli-cmd-system.c

示例2: malloc

void *layout_new (void)
{
  tp_layout *ret = (tp_layout*) malloc (sizeof(tp_layout));

  ret->k = 1.0;
  ret->K1 = 0.06;
  ret->K2 = 0.024;
  ret->force = 1.0;
  //viewZone = 5.0; calculated by the quality level
  ret->theta = 0.7;
  ret->quality = 0;
  ret->nodesPerCell = 10;
  ret->maxTreeDepth = 100;

  ret->stabilizationLimit = 0.9;

  tp_rect universe = tp_Rect (-100, -100, 200, 200);
  ret->box = box_new (ret->nodesPerCell, ret->maxTreeDepth, universe);

  ret->nodes = dict_new (10000);

  layout_reset_energies (ret);

  layout_set_quality (ret, ret->quality);
  pthread_mutex_init (&mutex, NULL);
  return ret;
}
开发者ID:schnorr,项目名称:viva,代码行数:27,代码来源:layout.c

示例3: dict_new

static dict_t *pkgmk_confs_explode(dict_t * pkgmk_confs, list_t * ports)
{
	unsigned i, j;
	dict_t *exploded;
	char *key, *pkgmk_conf;
	list_t *list;
	port_t *port;

	exploded = dict_new();

	for (i = 0; i < pkgmk_confs->length; i++) {
		key = xstrdup(pkgmk_confs->elements[i]->key);
		pkgmk_conf = xstrdup(pkgmk_confs->elements[i]->value);
		if (!is_file(pkgmk_conf)) {
			warning("pkgmk's conf %s, not found!", pkgmk_conf);
			free(key);
			free(pkgmk_conf);
			continue;
		}
		list = list_query(ports, port_query_by_name, key);
		for (j = 0; j < list->length; j++) {
			port = list->elements[j];
			if (dict_get(exploded, port->name) == NULL)
				dict_add(exploded, port->name,
					 xstrdup(pkgmk_conf));
		}
		list_free(list, NULL);
		free(key);
		free(pkgmk_conf);
	}

	return exploded;
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:33,代码来源:port.c

示例4: make_seq_dict

static dict_t *
make_seq_dict (int argc, char **argv)
{
        char index[] = "4294967296"; // 1<<32
        int i        = 0;
        int ret      = 0;
        dict_t *dict = dict_new ();

        if (!dict)
                return NULL;

        for (i = 0; i < argc; i++) {
                snprintf(index, sizeof(index), "%d", i);
                ret = dict_set_str (dict, index, argv[i]);
                if (ret == -1)
                        break;
        }

        if (ret) {
                dict_destroy (dict);
                dict = NULL;
        }

        return dict;
}
开发者ID:lkzhd,项目名称:glusterfs-annotation,代码行数:25,代码来源:cli-cmd-system.c

示例5: dict_copy

dict* dict_copy(dict *d)
{
    dict *out;
    if (!d)
        return 0;
    out = dict_new(d->n);
#if defined (HASHMAP)
    hash_map_entry *e;
    hash_map_iterator *i = hash_map_front(d->dict);

    while (!hash_map_iterator_at_end(i))
    {
        e = hash_map_iterator_get(i);
        dict_entry_copy(e->k, e->v, out);
        hash_map_iterator_next(i);
    }
    hash_map_iterator_free(i);
    return out;
#elif defined(TSTC)
    tstc_call(d->dict, 0, dict_entry_copy, out);
    return out;
#else
    return 0;
#endif
}
开发者ID:wongm168,项目名称:PegDF,代码行数:25,代码来源:dict.c

示例6: class_method

PmReturn_t
class_method(pPmObj_t pinstance, pPmObj_t pfunc, pPmObj_t *r_pmeth)
{
    PmReturn_t retval = PM_RET_OK;
    uint8_t *pchunk;
    pPmMethod_t pmeth;
    pPmObj_t pattrs;
    uint8_t objid;

    /* Allocate a method */
    retval = heap_getChunk(sizeof(PmMethod_t), &pchunk);
    PM_RETURN_IF_ERROR(retval);
    OBJ_SET_TYPE(pchunk, OBJ_TYPE_MTH);

    /* Set method fields */
    pmeth = (pPmMethod_t)pchunk;
    pmeth->m_instance = (pPmInstance_t)pinstance;
    pmeth->m_func = (pPmFunc_t)pfunc;
    pmeth->m_attrs = C_NULL;

    /* Create the attributes dict */
    heap_gcPushTempRoot((pPmObj_t)pmeth, &objid);
    retval = dict_new(&pattrs);
    heap_gcPopTempRoot(objid);
    pmeth->m_attrs = (pPmDict_t)pattrs;

    *r_pmeth = (pPmObj_t)pmeth;
    return retval;
}
开发者ID:renlexing,项目名称:projects,代码行数:29,代码来源:class.c

示例7: class_instantiate

/* Returns an instance of the class by reference */
PmReturn_t
class_instantiate(pPmObj_t pclass, pPmObj_t *r_pobj)
{
    PmReturn_t retval = PM_RET_OK;
    uint8_t *pchunk;
    pPmObj_t pobj;
    pPmObj_t pattrs;
    uint8_t objid;

    /* Allocate a class instance */
    retval = heap_getChunk(sizeof(PmInstance_t), &pchunk);
    PM_RETURN_IF_ERROR(retval);
    pobj = (pPmObj_t)pchunk;
    OBJ_SET_TYPE(pobj, OBJ_TYPE_CLI);

    /* Set the instance's fields */
    ((pPmInstance_t)pobj)->cli_class = (pPmClass_t)pclass;
    ((pPmInstance_t)pobj)->cli_attrs = C_NULL;

    /* Create the attributes dict */
    heap_gcPushTempRoot(pobj, &objid);
    retval = dict_new(&pattrs);
    heap_gcPopTempRoot(objid);
    ((pPmInstance_t)pobj)->cli_attrs = (pPmDict_t)pattrs;

    /* TODO: Store pclass in __class__ attr */

    *r_pobj = pobj;
    return retval;
}
开发者ID:renlexing,项目名称:projects,代码行数:31,代码来源:class.c

示例8: awlenv_new

awlenv* awlenv_new(void) {
    awlenv* e = safe_malloc(sizeof(awlenv));
    e->parent = NULL;
    e->internal_dict = dict_new(awlval_copy_proxy, awlval_del_proxy);
    e->top_level = false;
    e->references = 1;
    return e;
}
开发者ID:8l,项目名称:awl,代码行数:8,代码来源:types.c

示例9: store_function

static void store_function(const char*name, value_t*value)
{
    ID id = rb_intern(name);
    if(!global->functions) {
        global->functions = dict_new(&ptr_type);
    }
    dict_put(global->functions, (void*)id, value);
}
开发者ID:luiseduardohdbackup,项目名称:cagekeeper,代码行数:8,代码来源:language_rb.c

示例10: awlval_dict

awlval* awlval_dict(void) {
    awlval* v = safe_malloc(sizeof(awlval));
    v->type = AWLVAL_DICT;
    v->count = 0;
    v->length = 0;
    v->d = dict_new(awlval_copy_proxy, awlval_del_proxy);
    return v;
}
开发者ID:8l,项目名称:awl,代码行数:8,代码来源:types.c

示例11: main

int main(){

	struct dictionary *d;
	int i;
	d = dict_new(1,0);
	int min;
	int nums[7];
	int keys[7];
	
	keys[0] = 9;
	nums[0] = 14; 
	
	keys[1] = 4;
	nums[1] = 7; 
	
	keys[2] = 12;
	nums[2] = 5; 
	
	keys[3] = 0;
	nums[3] = 15; 
	
	keys[4] = 2;
	nums[4] = 3; 
	
	keys[5] = 14;
	nums[5] = 4; 
	
	keys[6] = 5;
	nums[6] = 2; 
	
	printf("new\n");
	
	//~ printHash(d);
		
	for(i = 0; i < 7; i++){
		//~ printf("Inserting %d...\n",nums[i]);
		dict_set(d,keys[i],nums[i]);
		//~ printHash(d);
	}
	
	printHash(d);
	
	dict_set(d,2,8);
	printf("set key 2 con 8\n");
	printf("get key 2 = %d\n",dict_get(d,2));
	
	printf("delete key 2\n");
	dict_delete(d,2);
	printHash(d);
	
	printf("delete key 9\n");
	dict_delete(d,9);
	printHash(d);
	
	dict_free(d);


}
开发者ID:vitorohe,项目名称:Tarea3Alg,代码行数:58,代码来源:test_hash.c

示例12: cli_cmd_peer_probe_cbk

int
cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,
                   const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        dict_t                  *dict = NULL;
        int                     sent = 0;
        int                     parse_error = 0;

        if (!(wordcount == 3)) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROBE];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict)
                goto out;

        ret = dict_set_str (dict, "hostname", (char *)words[2]);
        if (ret)
                goto out;

        ret = valid_internet_address ((char *) words[2]);
        if (ret == 1) {
                ret = 0;
        } else {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }
/*        if (words[3]) {
                ret = dict_set_str (dict, "port", (char *)words[3]);
                if (ret)
                        goto out;
        }
*/
        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Peer probe failed");
        }
        return ret;
}
开发者ID:BillTheBest,项目名称:glusterfs,代码行数:57,代码来源:cli-cmd-peer.c

示例13: xmalloc

ini_t *ini_new(char *filepath)
{
	ini_t *self;

	self = xmalloc(sizeof(ini_t));
	self->filepath = xstrdup(filepath);
	self->sections = dict_new();
	return self;
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:9,代码来源:ini.c

示例14: qserver_init

int
qserver_init(void)
{
    qserver_log = log_register_type("QServer", "file:qserver.log");
    conf_register_reload(qserver_conf_read);
    qserver_dict = dict_new();
    reg_exit_func(qserver_cleanup, NULL);
    return 1;
}
开发者ID:Cloudxtreme,项目名称:x3,代码行数:9,代码来源:mod-qserver.c

示例15: initialize_parser

void initialize_parser()
{
    global = rfx_calloc(sizeof(global_t));
    global->file = abc_file_new();
    global->file->flags &= ~ABCFILE_LAZY;
    global->file2token2info = dict_new();
    global->token2info = 0;
    global->classinit = abc_initscript(global->file);
}
开发者ID:DJwa163,项目名称:swftools,代码行数:9,代码来源:parser_help.c


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