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


C++ cache_enter函数代码示例

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


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

示例1: main

main()
{
    CACHE *cache;
    char cmd[2];
    int val, *pval;

    /* Print some instructions. */
    printf("This program demonstrates the various cache manipulation\n");
    printf("routines supplied by this package.  Although this program\n");
    printf("manipulates a cache of integers, data of any type and size\n");
    printf("(and not just integers) are supported by the routines.  See\n");
    printf("the man page for more information.\n\n");
    printf("We illustrate a cache with a maximum size of 3 entries.\n\n");

    /* Allocate a new cache. */
    cache = cache_init(MAX_ELEMENTS);
    print_cache(cache);

    /* Get some commands. */
    printf("\n(e)nter new element, (c)heck for element; (q)uit: ");
    while (scanf("%1s", cmd) != EOF) {
        switch (cmd[0]) {
        case 'e':
            printf("Value (int) to enter: ");
            if (scanf("%d", &val)) {
                /* We ignore the return code here, but in practice,
                * we may fail (with a return code of NULL).
                */
                cache_enter(cache, &val, sizeof(val), &pval);
                if (pval != NULL) {
                    printf("%d was removed to make room.\n", *pval);
                }
            }
            break;
        case 'c':
            printf("Value (int) to check for: ");
            if (scanf("%d", &val)) {
                pval = (int *) cache_check(cache, (char *) &val, match);
                if (pval != NULL) {
                    printf("%d found!\n", *pval);
                }
                else {
                    printf("Not found.\n");
                }
            }
            break;
        case 'q':
            cache_free(cache, CACHE_DEALLOC);
            exit(0);
            break;
        default:
            printf("'%s' not a recognized command!\n", cmd);
            break;
        }
        print_cache(cache);
        printf("\n(e)nter new element, (c)heck for element; (q)uit: ");
    }

    exit(0);
}
开发者ID:liei,项目名称:ttk4145,代码行数:60,代码来源:cachetest.c

示例2: fuse_vnode_get

int
fuse_vnode_get(struct mount         *mp,
               uint64_t              nodeid,
               struct vnode         *dvp,
               struct vnode         **vpp,
               struct componentname *cnp,
               enum vtype            vtyp)
{
    struct thread *td = (cnp != NULL ? cnp->cn_thread : curthread);
    int err = 0;

    debug_printf("dvp=%p\n", dvp);

    err = fuse_vnode_alloc(mp, td, nodeid, vtyp, vpp);
    if (err) {
        return err;
    }

    if (dvp != NULL) {
        MPASS((cnp->cn_flags & ISDOTDOT) == 0);
        MPASS(!(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.'));
        fuse_vnode_setparent(*vpp, dvp);
    }
    if (dvp != NULL && cnp != NULL && (cnp->cn_flags & MAKEENTRY) != 0) {
        ASSERT_VOP_LOCKED(*vpp, "fuse_vnode_get");
        ASSERT_VOP_LOCKED(dvp, "fuse_vnode_get");
        cache_enter(dvp, *vpp, cnp);
    }
    VTOFUD(*vpp)->nlookup++;

    return 0;
}
开发者ID:glk,项目名称:fuse-freebsd,代码行数:32,代码来源:fuse_node.c

示例3: safe_event_disassemble

static void safe_event_disassemble(void * x) {
    DisassembleCmdArgs * args = (DisassembleCmdArgs *)x;
    if (!is_channel_closed(args->c)) {
        cache_enter(disassemble_cache_client, args->c, args, sizeof(DisassembleCmdArgs));
    }
    channel_unlock(args->c);
    loc_free(args);
}
开发者ID:wind-river-cdt,项目名称:tcf.agent,代码行数:8,代码来源:disassembly.c

示例4: command_list

static void command_list(char * token, Channel * c) {
    CommandListArgs args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_list_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:10,代码来源:symbols.c

示例5: command_getm

static void command_getm(char * token, Channel * c) {
    GetmArgs args;

    args.locs = read_location_list(&c->inp, &args.locs_cnt);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_getm_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:10,代码来源:registers.c

示例6: command_get_location_info

static void command_get_location_info(char * token, Channel * c) {
    CommandGetLocationInfo args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_get_location_info_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:10,代码来源:symbols.c

示例7: command_get_capabilities

static void command_get_capabilities(char * token, Channel * c) {
    GetCapabilitiesCmdArgs args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
    if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_get_capabilities_cache_client, c, &args, sizeof(args));
}
开发者ID:pkdevbox,项目名称:tcf.agent,代码行数:10,代码来源:disassembly.c

示例8: command_setm

static void command_setm(char * token, Channel * c) {
    SetmArgs args;

    args.locs = read_location_list(&c->inp, &args.locs_cnt);
    json_test_char(&c->inp, MARKER_EOA);
    args.data = (uint8_t *)json_read_alloc_binary(&c->inp, &args.data_len);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_setm_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:12,代码来源:registers.c

示例9: command_set

static void command_set(char * token, Channel * c) {
    SetArgs args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    args.data = (uint8_t *)json_read_alloc_binary(&c->inp, &args.data_len);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_set_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:12,代码来源:registers.c

示例10: command_find_by_addr

static void command_find_by_addr(char * token, Channel * c) {
    CommandFindByAddrArgs args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    args.addr = (ContextAddress)json_read_uint64(&c->inp);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_find_by_addr_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:12,代码来源:symbols.c

示例11: command_get_sym_file_info

static void command_get_sym_file_info(char * token, Channel * c) {
    CommandSymFileInfo args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    args.addr = (ContextAddress)json_read_uint64(&c->inp);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_get_sym_file_info_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:12,代码来源:symbols.c

示例12: command_get_array_type

static void command_get_array_type(char * token, Channel * c) {
    CommandGetArrayTypeArgs args;

    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    args.length = json_read_uint64(&c->inp);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_get_array_type_cache_client, c, &args, sizeof(args));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:12,代码来源:symbols.c

示例13: strcpy

HEADER *headersDepth(const char *t, time_t time, int depth)
{
	HEADER hdr, *h = &hdr;
	LIST *l;
	const char* cachekey=t;

	/* D support (doesn't affect C(++), because a source file is never included) */
	if(depth == 0)
	{
		cachekey=malloc(strlen(t)+sizeof("source:"));
		strcpy((char*)cachekey,"source:");
		strcpy((char*)cachekey+7,t);
	}
	
	if (!headerhash)
		headerhash = hashinit(sizeof(HEADER), "headers");

	h->key = cachekey;
	h->includes = 0;
	h->time = time;
	h->headers = 0;
	h->newest = 0;
	if (!hashenter(headerhash, (HASHDATA **)&h))
		return h;

	h->key = newstr(t);
#ifdef USE_CACHE
	if (!cache_check(cachekey, time, &h->includes))
	{
		h->includes = headers1(t, depth);
		cache_enter(cachekey, time, h->includes);
	}
#else
	h->includes = headers1(t, depth);
#endif
	if(depth == 0)
		free((char*)cachekey);

	l = h->includes;
	while (l)
	{
		const char *t2 = search(t, l->string, &time);
		if (time)
			h->headers = headerentry(h->headers, headersDepth(t2, time, depth+1));
		l = list_next(l);
	}

	return h;
}
开发者ID:simple-codeblocks,项目名称:Codeblocks,代码行数:49,代码来源:headers.c

示例14: command_find_by_name_args

static void command_find_by_name_args(char * token, Channel * c, CommandFindByNameArgs * args) {
    args->ip = 0;
    json_read_string(&c->inp, args->id, sizeof(args->id));
    json_test_char(&c->inp, MARKER_EOA);
    if (json_peek(&c->inp) != '"' && json_peek(&c->inp) != 'n') {
        args->ip = (ContextAddress)json_read_uint64(&c->inp);
        json_test_char(&c->inp, MARKER_EOA);
    }
    args->name = json_read_alloc_string(&c->inp);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args->token, token, sizeof(args->token));
    cache_enter(command_find_by_name_cache_client, c, args, sizeof(CommandFindByNameArgs));
}
开发者ID:tom3333,项目名称:tcf.agent,代码行数:15,代码来源:symbols.c

示例15: command_reset

static void command_reset(char * token, Channel * c) {
    CommandResetArgs args;

    memset(&args, 0, sizeof(args));
    json_read_string(&c->inp, args.id, sizeof(args.id));
    json_test_char(&c->inp, MARKER_EOA);
    json_read_string(&c->inp, args.type, sizeof(args.type));
    json_test_char(&c->inp, MARKER_EOA);
    json_read_struct(&c->inp, read_reset_params, &args.params);
    json_test_char(&c->inp, MARKER_EOA);
    json_test_char(&c->inp, MARKER_EOM);

    strlcpy(args.token, token, sizeof(args.token));
    cache_enter(command_reset_cache_client, c, &args, sizeof(args));
}
开发者ID:eclipse,项目名称:tcf.agent,代码行数:15,代码来源:contextreset.c


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