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


C++ cli_calloc函数代码示例

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


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

示例1: fileblobCreate

fileblob *
fileblobCreate(void)
{
#ifdef	CL_DEBUG
    fileblob *fb = (fileblob *)cli_calloc(1, sizeof(fileblob));
    if(fb)
        fb->b.magic = BLOBCLASS;
    cli_dbgmsg("blobCreate\n");
    return fb;
#else
    return (fileblob *)cli_calloc(1, sizeof(fileblob));
#endif
}
开发者ID:nsxz,项目名称:clamav-devel,代码行数:13,代码来源:blob.c

示例2: blobCreate

blob *
blobCreate(void)
{
#ifdef	CL_DEBUG
    blob *b = (blob *)cli_calloc(1, sizeof(blob));
    if(b)
        b->magic = BLOBCLASS;
    cli_dbgmsg("blobCreate\n");
    return b;
#else
    return (blob *)cli_calloc(1, sizeof(blob));
#endif
}
开发者ID:nsxz,项目名称:clamav-devel,代码行数:13,代码来源:blob.c

示例3: cli_calloc

cli_events_t *cli_events_new(unsigned max_event)
{
    struct cli_events *ev = cli_calloc(1, sizeof(*ev));
    if (!ev)
	return NULL;
    ev->max = max_event;
    ev->events = cli_calloc(max_event, max_event * sizeof(*ev->events));
    if (!ev->events) {
	free(ev);
	return NULL;
    }
    ev->errors.name = "errors";
    ev->errors.type = ev_string;
    ev->errors.multiple = multiple_chain;
    return ev;
}
开发者ID:Distrotech,项目名称:clamav,代码行数:16,代码来源:events.c

示例4: cli_addtypesigs

int cli_addtypesigs(struct cl_engine *engine)
{
	int i, ret;
	struct cli_matcher *root;


    if(!engine->root[0]) {
	cli_dbgmsg("cli_addtypesigs: Need to allocate AC trie in engine->root[0]\n");
	root = engine->root[0] = (struct cli_matcher *) cli_calloc(1, sizeof(struct cli_matcher));
	if(!root) {
	    cli_errmsg("cli_addtypesigs: Can't initialise AC pattern matcher\n");
	    return CL_EMEM;
	}

	if((ret = cli_ac_init(root, cli_ac_mindepth, cli_ac_maxdepth))) {
	    /* No need to free previously allocated memory here - all engine
	     * elements will be properly freed by cl_free()
	     */
	    cli_errmsg("cli_addtypesigs: Can't initialise AC pattern matcher\n");
	    return ret;
	}
    } else {
	root = engine->root[0];
    }

    for(i = 0; cli_smagic[i].sig; i++) {
	if((ret = cli_parse_add(root, cli_smagic[i].descr, cli_smagic[i].sig, cli_smagic[i].type, NULL, 0))) {
	    cli_errmsg("cli_addtypesigs: Problem adding signature for %s\n", cli_smagic[i].descr);
	    return ret;
	}
    }

    return 0;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:34,代码来源:libclamav_filetypes.c

示例5: START_TEST

END_TEST

START_TEST (test_bm_scanbuff) {
	struct cli_matcher *root;
	const char *virname = NULL;
	int ret;


    root = (struct cli_matcher *) cli_calloc(1, sizeof(struct cli_matcher));
    fail_unless(root != NULL, "root == NULL");

#ifdef USE_MPOOL
    root->mempool = mpool_create();
#endif
    ret = cli_bm_init(root);
    fail_unless(ret == CL_SUCCESS, "cli_bm_init() failed");

    ret = cli_parse_add(root, "Sig1", "deadbabe", 0, 0, NULL, 0, NULL, 0);
    fail_unless(ret == CL_SUCCESS, "cli_parse_add() failed");
    ret = cli_parse_add(root, "Sig2", "deadbeef", 0, 0, NULL, 0, NULL, 0);
    fail_unless(ret == CL_SUCCESS, "cli_parse_add() failed");
    ret = cli_parse_add(root, "Sig3", "babedead", 0, 0, NULL, 0, NULL, 0);
    fail_unless(ret == CL_SUCCESS, "cli_parse_add() failed");

    ret = cli_bm_scanbuff("blah\xde\xad\xbe\xef", 12, &virname, root, 0, 0, -1);
    fail_unless(ret == CL_VIRUS, "cli_bm_scanbuff() failed");
    fail_unless(!strncmp(virname, "Sig2", 4), "Incorrect signature matched in cli_bm_scanbuff()\n");
    cli_bm_free(root);
#ifdef USE_MPOOL
    mpool_destroy(root->mempool);
#endif
    free(root);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:33,代码来源:check_matchers.c

示例6: cli_LzmaInitUPX

int cli_LzmaInitUPX(CLI_LZMA **Lp, uint32_t dictsz) {
  CLI_LZMA *L = *Lp;

  if(!L) {
    *Lp = L = cli_calloc(sizeof(*L), 1);
    if(!L) {
      return LZMA_RESULT_DATA_ERROR;
    }
  }

  L->state.Properties.pb = 2; /* FIXME: these  */
  L->state.Properties.lp = 0; /* values may    */
  L->state.Properties.lc = 3; /* not be static */

  L->state.Properties.DictionarySize = dictsz;

  if (!(L->state.Probs = (CProb *)cli_malloc(LzmaGetNumProbs(&L->state.Properties) * sizeof(CProb))))
    return LZMA_RESULT_DATA_ERROR;

  if (!(L->state.Dictionary = (unsigned char *)cli_malloc(L->state.Properties.DictionarySize))) {
    free(L->state.Probs);
    return LZMA_RESULT_DATA_ERROR;
  }

  L->initted = 1;

  LzmaDecoderInit(&L->state);
  return LZMA_RESULT_OK;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:29,代码来源:lzma_iface.c

示例7: START_TEST

END_TEST

START_TEST (test_pcre_scanbuff_allscan) {
	struct cli_ac_data mdata;
	struct cli_matcher *root;
	char *hexsig;
	unsigned int i, hexlen;
	int ret;

    root = ctx.engine->root[0];
    fail_unless(root != NULL, "root == NULL");

#ifdef USE_MPOOL
    root->mempool = mpool_create();
#endif
    ret = cli_pcre_init();
    fail_unless(ret == CL_SUCCESS, "[pcre] cli_pcre_init() failed");

    for(i = 0; pcre_testdata[i].data; i++) {
	hexlen = strlen(PCRE_BYPASS) + strlen(pcre_testdata[i].hexsig) + 1;

	hexsig = cli_calloc(hexlen, sizeof(char));
	fail_unless(hexsig != NULL, "[pcre] failed to prepend bypass (out-of-memory)");

	strncat(hexsig, PCRE_BYPASS, hexlen);
	strncat(hexsig, pcre_testdata[i].hexsig, hexlen);

	ret = cli_parse_add(root, pcre_testdata[i].virname, hexsig, 0, 0, 0, pcre_testdata[i].offset, 0, NULL, 0);
	fail_unless(ret == CL_SUCCESS, "[pcre] cli_parse_add() failed");
	free(hexsig);
    }

    ret = cli_pcre_build(root, CLI_DEFAULT_PCRE_MATCH_LIMIT, CLI_DEFAULT_PCRE_RECMATCH_LIMIT, NULL);
    fail_unless(ret == CL_SUCCESS, "[pcre] cli_pcre_build() failed");

    // recomputate offsets

    ret = cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, root->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN);
    fail_unless(ret == CL_SUCCESS, "[pcre] cli_ac_initdata() failed");

    ctx.options |= CL_SCAN_ALLMATCHES;
    for(i = 0; pcre_testdata[i].data; i++) {
	ret = cli_pcre_scanbuf((const unsigned char*)pcre_testdata[i].data, strlen(pcre_testdata[i].data), &virname, NULL, root, NULL, NULL, NULL);
	fail_unless_fmt(ret == pcre_testdata[i].expected_result, "[pcre] cli_pcre_scanbuff() failed for %s (%d != %d)", pcre_testdata[i].virname, ret, pcre_testdata[i].expected_result);
	if (pcre_testdata[i].expected_result == CL_VIRUS)
	    fail_unless_fmt(!strncmp(virname, pcre_testdata[i].virname, strlen(pcre_testdata[i].virname)), "[pcre] Dataset %u matched with %s", i, virname);

	ret = cli_scanbuff((const unsigned char*)pcre_testdata[i].data, strlen(pcre_testdata[i].data), 0, &ctx, 0, NULL);
	fail_unless_fmt(ret == pcre_testdata[i].expected_result, "[pcre] cli_scanbuff() failed for %s", pcre_testdata[i].virname);
	/* num_virus field add to test case struct */
	if (ctx.num_viruses)
	    ctx.num_viruses = 0;
    }

    cli_ac_freedata(&mdata);
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:56,代码来源:check_matchers.c

示例8: onas_ddd_init_wdlt

static int onas_ddd_init_wdlt(uint64_t nwatches) {

	if (nwatches <= 0) return CL_EARG;

	wdlt = (char **) cli_calloc(nwatches << 1, sizeof(char*));
	if (!wdlt) return CL_EMEM;

	wdlt_len = nwatches << 1;

	return CL_SUCCESS;
}
开发者ID:xiongjungit,项目名称:clamav-devel,代码行数:11,代码来源:onaccess_ddd.c

示例9: UNUSEDPARAM

void *__lzma_wrap_alloc(void *unused, size_t size) { 
    UNUSEDPARAM(unused);
    if(!size || size > CLI_MAX_ALLOCATION)
	return NULL;
    if(!size || size > CLI_MAX_ALLOCATION) {
	cli_dbgmsg("lzma_wrap_alloc(): Attempt to allocate %lu bytes.\n", (unsigned long int) size);
	return NULL;
    }

    return cli_calloc(1, size);
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:11,代码来源:lzma_iface.c

示例10: cli_pcre_compile

int cli_pcre_compile(struct cli_pcre_data *pd, long long unsigned match_limit, long long unsigned match_limit_recursion, unsigned int options, int opt_override)
{
    const char *error;
    int erroffset;

    if (!pd || !pd->expression) {
        cli_errmsg("cli_pcre_compile: NULL pd or NULL pd->expression\n");
        return CL_ENULLARG;
    }

    /* compile the pcre regex last arg is charset, allow for options override */
    if (opt_override)
        pd->re = pcre_compile(pd->expression, options, &error, &erroffset, NULL); /* pd->re handled by pcre -> call pcre_free() -> calls free() */
    else
        pd->re = pcre_compile(pd->expression, pd->options, &error, &erroffset, NULL); /* pd->re handled by pcre -> call pcre_free() -> calls free() */
    if (pd->re == NULL) {
        cli_errmsg("cli_pcre_compile: PCRE compilation failed at offset %d: %s\n", erroffset, error);
        return CL_EMALFDB;
    }

    /* now study it... (section totally not from snort) */
    pd->ex = pcre_study(pd->re, 0, &error);
    if (!(pd->ex)) {
        pd->ex = (pcre_extra *)cli_calloc(1, sizeof(*(pd->ex)));
        if (!(pd->ex)) {
            cli_errmsg("cli_pcre_compile: Unable to allocate memory for extra data\n");
            return CL_EMEM;
        }
    }

    /* set the match limits */
    if (pd->ex->flags & PCRE_EXTRA_MATCH_LIMIT) {
        pd->ex->match_limit = match_limit;
    }
    else {
        pd->ex->flags |= PCRE_EXTRA_MATCH_LIMIT;
        pd->ex->match_limit = match_limit;
    }

    /* set the recursion match limits */
#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
    if (pd->ex->flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) {
        pd->ex->match_limit_recursion = match_limit_recursion;
    }
    else {
        pd->ex->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
        pd->ex->match_limit_recursion = match_limit_recursion;
    }
#endif /* PCRE_EXTRA_MATCH_LIMIT_RECURSION */

    /* non-dynamic allocated fields set by caller */
    return CL_SUCCESS;
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:53,代码来源:regex_pcre.c

示例11: cli_calloc

struct uniq *uniq_init(uint32_t count) {
  struct uniq *U;

  if(!count) return NULL;
  U = cli_calloc(1, sizeof(*U));
  if(!U) return NULL;

  U->md5s = cli_malloc(count * sizeof(*U->md5s));
  if(!U->md5s) {
    uniq_free(U);
    return NULL;
  }

  return U;
}
开发者ID:rossguide,项目名称:clamav-devel,代码行数:15,代码来源:uniq.c

示例12: hashtab_init

int hashtab_init(struct hashtable *s,size_t capacity)
{
	if(!s)
		return CL_ENULLARG;

	PROFILE_INIT(s);

	capacity = get_nearest_capacity(capacity);
	s->htable = cli_calloc(capacity,sizeof(*s->htable));
	if(!s->htable)
		return CL_EMEM;
	s->capacity = capacity;
	s->used = 0;
	s->maxfill = 8*capacity/10;
	return 0;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:16,代码来源:libclamav_hashtab.c

示例13: scope_new

static struct scope* scope_new(struct parser_state *state)
{
	struct scope *parent = state->current;
	struct scope *s = cli_calloc(1, sizeof(*s));
	if(!s)
		return NULL;
	if(cli_hashtab_init(&s->id_map, 10) < 0) {
		free(s);
		return NULL;
	}
	s->parent = parent;
	s->fsm_state = Base;
	s->nxt = state->list;
	state->list = s;
	state->current = s;
	return s;
}
开发者ID:oozie,项目名称:clamav-devel,代码行数:17,代码来源:js-norm.c

示例14:

char *cli_str2hex(const char *string, unsigned int len)
{
	char *hexstr;
	char HEX[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
		       'a', 'b', 'c', 'd', 'e', 'f' };
	unsigned int i, j;

    if((hexstr = (char *) cli_calloc(2 * len + 1, sizeof(char))) == NULL)
	return NULL;

    for(i = 0, j = 0; i < len; i++, j += 2) {
	hexstr[j] = HEX[(string[i] >> 4) & 0xf];
	hexstr[j + 1] = HEX[string[i] & 0xf];
    }

    return hexstr;
}
开发者ID:rossguide,项目名称:clamav-devel,代码行数:17,代码来源:str.c

示例15: hashtab_grow

static int hashtab_grow(struct hashtable *s)
{
	const size_t new_capacity = get_nearest_capacity(s->capacity);
	struct element* htable = cli_calloc(new_capacity, sizeof(*s->htable));
	size_t i,idx, used = 0;
	if(new_capacity == s->capacity || !htable)
		return CL_EMEM;

	PROFILE_GROW_START(s);
	cli_dbgmsg("hashtab.c: Warning: growing open-addressing hashtables is slow. Either allocate more storage when initializing, or use other hashtable types!\n");
	for(i=0; i < s->capacity;i++) {
		if(s->htable[i].key && s->htable[i].key != DELETED_KEY) {
			struct element* element;
			size_t tries = 1;				

			PROFILE_CALC_HASH(s);
			idx = hash(s->htable[i].key, strlen((const char*)s->htable[i].key), new_capacity);
			element = &htable[idx];

			while(element->key && tries <= new_capacity) {
				idx = (idx + tries++) % new_capacity;
				element = &htable[idx];
			}
			if(!element->key) {
				/* copy element from old hashtable to new */
				PROFILE_GROW_FOUND(s, tries);
				*element = s->htable[i];
				used++;
			}
			else {
				cli_errmsg("hashtab.c: Impossible - unable to rehash table");
				return CL_EMEM;/* this means we didn't find enough room for all elements in the new table, should never happen */ 
			}
		}
	}
	free(s->htable);
	s->htable = htable;
	s->used = used;
	s->capacity = new_capacity;
	s->maxfill = new_capacity*8/10;
	cli_dbgmsg("Table %p size after grow:%ld\n",(void*)s,s->capacity);
	PROFILE_GROW_DONE(s);
	return CL_SUCCESS;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:44,代码来源:libclamav_hashtab.c


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