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


C++ pool_create函数代码示例

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


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

示例1: t_field_map

void
t_field_map(void)
{
    pool_reference list_pool = pool_create(LIST_TYPE_ID);
    CU_ASSERT_NOT_EQUAL_FATAL(list_pool, NULL_POOL);

    global_reference head = pool_alloc(&list_pool);
    pool_iterator itr = iterator_new(&list_pool, &head);

    size_t list_size = 10000;

    for (size_t i = 0 ; i < list_size ; ++i) {
        iterator_set_field(itr, 1, &i);
        iterator_list_insert(itr, pool_alloc(&list_pool));
        itr = iterator_next(list_pool, itr);
    }

    pool_reference long_pool = pool_create(LONG_TYPE_ID);
    CU_ASSERT_NOT_EQUAL_FATAL(long_pool, NULL_POOL);

    CU_ASSERT_EQUAL(field_map(list_pool, &long_pool, 1, square), 0);

    uint64_t *result = pool_to_array(long_pool);

    int cmp_error_count = 0;
    for (size_t i = 0 ; i < list_size ; ++i) {
        cmp_error_count += i*i != result[i];
    }

    CU_ASSERT_EQUAL(cmp_error_count, 0);

    iterator_destroy(&itr);
    pool_destroy(&long_pool);
    pool_destroy(&list_pool);
}
开发者ID:jupvfranco,项目名称:ohmm,代码行数:35,代码来源:test_pool_map.c

示例2: profile_palloc_single_chars

static unsigned long long
profile_palloc_single_chars(const unsigned long iterations)
{
    struct timeval start;
    struct timeval stop;

    pool_reference char_ref_pool = pool_create(CHAR_REF_TYPE_ID);
    pool_reference char_pool = pool_create(CHAR_TYPE_ID);

    pool_grow(&char_ref_pool, iterations);
    
    global_reference *char_refs = pool_to_array(char_ref_pool);

    gettimeofday(&start, NULL);
    for (unsigned long i = 0 ; i < iterations ; ++i) {
        char_refs[i] = pool_alloc(&char_pool);
    }
    gettimeofday(&stop, NULL);

    pool_destroy(&char_ref_pool);
    pool_destroy(&char_pool);

    return ((stop.tv_sec - start.tv_sec) * 1000000LLU) +
            stop.tv_usec - start.tv_usec; 
}
开发者ID:jupvfranco,项目名称:ohmm,代码行数:25,代码来源:alloc_benchmark.c

示例3: glw_init

int
glw_init(glw_root_t *gr, const char *theme,
	 ui_t *ui, int primary, 
	 const char *instance, const char *instance_title)
{
  hts_mutex_init(&gr->gr_mutex);
  gr->gr_courier = prop_courier_create_passive();
  gr->gr_token_pool = pool_create("glwtokens", sizeof(token_t), POOL_ZERO_MEM);
  gr->gr_clone_pool = pool_create("glwclone", sizeof(glw_clone_t),
				  POOL_ZERO_MEM);

  gr->gr_vpaths[0] = "theme";
  gr->gr_vpaths[1] = theme;
  gr->gr_vpaths[2] = NULL;

  gr->gr_uii.uii_ui = ui;

  glw_text_bitmap_init(gr);
  glw_init_settings(gr, instance, instance_title);

  TAILQ_INIT(&gr->gr_destroyer_queue);
  glw_tex_init(gr);

  gr->gr_frameduration = 1000000 / 60;
  uii_register(&gr->gr_uii, primary);

  return 0;
}
开发者ID:Daisho,项目名称:showtime,代码行数:28,代码来源:glw.c

示例4: initialize

void initialize(void) {

	cwmp_log_init(NULL, CWMP_LOG_DEBUG);

	gpool = (pool_t*)pool_create(POOL_DEFAULT_SIZE);
	gcwmp = (cwmp_t*)pool_palloc(gpool, sizeof(cwmp_t));
	if(!gcwmp)
	{
		cwmp_log_error("create cwmp_t error!");
		exit(-1);
	}
	cwmp_log_debug("cwmp at %p", gcwmp);
	if(!gcwmp->pool)
	{
		cwmp_log_debug("cwmp pool at %p", gpool);
		gcwmp->pool = gpool;   
	}

	cwmp_model_load_xml(gcwmp, "device.xml", NULL, 0);

	char * envstr;
	char * encstr;

	envstr = "SOAP-ENV"; //cwmp_conf_get("cwmp:soap_env");
	encstr = "SOAP-ENC"; // cwmp_conf_get("cwmp:soap_enc");

	cwmp_set_envelope_ns(envstr, encstr);

}
开发者ID:HankMa,项目名称:netcwmp,代码行数:29,代码来源:testutil.c

示例5: seed_concurrent_queue_create

IQueue*
seed_concurrent_queue_create(size_t limit) {
	Queue* q;
	if ((q = malloc(sizeof(Queue)+sizeof(IQueue))) == NULL) {
		return NULL;
	}
	if ((q->mutex = (Mutex*)malloc(sizeof(Mutex))) == NULL) {
		free(q);
		return NULL;
	}
	if ((q->pool = pool_create(limit, sizeof(Node))) == NULL) {
		mutex_release(q->mutex);
		free(q);
		return NULL;
	}
	mutex_init(q->mutex, NULL);
	q->tail = q->head = NULL;

	IQueue* queue = (IQueue*)q->methods;
	queue->enqueue      = &enqueue;
	queue->dequeue      = &dequeue;
	queue->batchDequeue = &batchDequeue;
	queue->release      = &release;
	return queue;
}
开发者ID:phyxdown,项目名称:cat.c,代码行数:25,代码来源:concurrent.c

示例6: fopen

config_t *load_config(pool_t *proc, const char *conf_path) {
	char *line = NULL;
	size_t len = 0;
	int rv;
	pool_t *tmp_pool;
	config_t *conf;

	FILE *fp = fopen(conf_path, "r");
	if (!fp) {
		fprintf(stderr, "Unable to open config file %s. Error %s", conf_path, strerror(errno));
		return NULL;
	}

	tmp_pool = pool_create(proc, "temporary config pool");
	conf = pool_alloc(proc, sizeof(*conf), "config object");

	/* format is A=B\n. Lines starting with # are comments. Empty lines are allowed. WS is allowed */
	while ((rv = readline(tmp_pool, &line, fp)) > 0) {
		char *l = line;
		while (isspace(*l)) l++;
		if ((l[0] != '#') && (l[0] != '\0'))  {
			process_config_line(proc, conf, l); 
		}
	}
	if (!feof(fp)) {
		fprintf(stderr, "Error while reading config file %s. Error %s", conf_path, strerror(ferror(fp)));
		pool_destroy(tmp_pool);
		return NULL;
	}
	pool_destroy(tmp_pool);
	return conf;
}
开发者ID:Krabby127,项目名称:misc,代码行数:32,代码来源:config.c

示例7: classification_test_destroy_cos

void classification_test_destroy_cos(void)
{
	odp_cos_t cos;
	char name[ODP_COS_NAME_LEN];
	odp_pool_t pool;
	odp_queue_t queue;
	odp_cls_cos_param_t cls_param;
	int retval;

	pool = pool_create("cls_basic_pool");
	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);

	queue = queue_create("cls_basic_queue", true);
	CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);

	sprintf(name, "ClassOfService");
	odp_cls_cos_param_init(&cls_param);
	cls_param.pool = pool;
	cls_param.queue = queue;
	cls_param.drop_policy = ODP_COS_DROP_POOL;

	cos = odp_cls_cos_create(name, &cls_param);
	CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
	retval = odp_cos_destroy(cos);
	CU_ASSERT(retval == 0);
	retval = odp_cos_destroy(ODP_COS_INVALID);
	CU_ASSERT(retval < 0);

	odp_pool_destroy(pool);
	odp_queue_destroy(queue);
}
开发者ID:guanhe0,项目名称:packages,代码行数:31,代码来源:odp_classification_basic.c

示例8: classification_test_cos_set_drop

void classification_test_cos_set_drop(void)
{
	int retval;
	char cosname[ODP_COS_NAME_LEN];
	odp_cos_t cos_drop;
	odp_queue_t queue;
	odp_pool_t pool;
	odp_cls_cos_param_t cls_param;

	pool = pool_create("cls_basic_pool");
	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);

	queue = queue_create("cls_basic_queue", true);
	CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);

	sprintf(cosname, "CoSDrop");
	odp_cls_cos_param_init(&cls_param);
	cls_param.pool = pool;
	cls_param.queue = queue;
	cls_param.drop_policy = ODP_COS_DROP_POOL;
	cos_drop = odp_cls_cos_create(cosname, &cls_param);
	CU_ASSERT_FATAL(cos_drop != ODP_COS_INVALID);

	retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_POOL);
	CU_ASSERT(retval == 0);
	retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_NEVER);
	CU_ASSERT(retval == 0);
	odp_cos_destroy(cos_drop);
	odp_pool_destroy(pool);
	odp_queue_destroy(queue);
}
开发者ID:guanhe0,项目名称:packages,代码行数:31,代码来源:odp_classification_basic.c

示例9: START_TEST

END_TEST

START_TEST(test_version_split)
{
    Pool *pool = pool_create();
    char evr[] = "1:5.9.3-8";
    char *epoch, *version, *release;

    pool_split_evr(pool, evr, &epoch, &version, &release);
    ck_assert_str_eq(epoch, "1");
    ck_assert_str_eq(version, "5.9.3");
    ck_assert_str_eq(release, "8");

    char evr2[] = "8.0-9";
    pool_split_evr(pool, evr2, &epoch, &version, &release);
    fail_unless(epoch == NULL);
    ck_assert_str_eq(version, "8.0");
    ck_assert_str_eq(release, "9");

    char evr3[] = "1.4";
    pool_split_evr(pool, evr3, &epoch, &version, &release);
    fail_unless(epoch == NULL);
    ck_assert_str_eq(version, "1.4");
    fail_unless(release == NULL);

    pool_free(pool);
}
开发者ID:MichaelMraka,项目名称:libhif,代码行数:27,代码来源:test_iutil.c

示例10: main

int main(void) {
    lcb_pool_t pool;
    lcb_t instance;
    struct lcb_create_st options;
    lcb_error_t error;

    /* set up the options to represent your cluster (hostname etc) */
    /* ... */

    /* Create the pool */
    error = pool_create(10, &options, &pool, initiate);
    if (error != LCB_SUCCESS) {
        fprintf(stderr, "Failed to create pool: %s\n",
                lcb_strerror(NULL, error));
        exit(EXIT_FAILURE);
    }

    /*
     * Every time you want to use libcouchbase you would grab an instance
     * from the pool by:
     */
    instance = pool_pop(pool);

    /* use the instance for whatever you wanted to do */


    /*
     * When you're done using the instance you would put it back into the
     * pool (and ready for others to use) by:
     */
    pool_push(pool, instance);

    return 0;
}
开发者ID:a-c-m,项目名称:couchnode,代码行数:34,代码来源:main.c

示例11: main

int
main(int argc, char **argv)
{
  Pool *pool;
  Repo *repo;
  int with_attr = 0;
#ifdef SUSE
  int add_auto = 0;
#endif
  int c;

  pool = pool_create();
  repo = repo_create(pool, "<mergesolv>");
  
  while ((c = getopt(argc, argv, "ahX")) >= 0)
    {
      switch (c)
      {
	case 'h':
	  usage();
	  break;
	case 'a':
	  with_attr = 1;
	  break;
	case 'X':
#ifdef SUSE
	  add_auto = 1;
#endif
	  break;
	default:
	  usage();
	  exit(1);
      }
    }
  if (with_attr)
    pool_setloadcallback(pool, loadcallback, 0);

  for (; optind < argc; optind++)
    {
      FILE *fp;
      if ((fp = fopen(argv[optind], "r")) == NULL)
	{
	  perror(argv[optind]);
	  exit(1);
	}
      if (repo_add_solv(repo, fp, 0))
	{
	  fprintf(stderr, "repo %s: %s\n", argv[optind], pool_errstr(pool));
	  exit(1);
	}
      fclose(fp);
    }
#ifdef SUSE
  if (add_auto)
    repo_add_autopattern(repo, 0);
#endif
  tool_write(repo, stdout);
  pool_free(pool);
  return 0;
}
开发者ID:rpm-software-management,项目名称:libsolv,代码行数:60,代码来源:mergesolv.c

示例12: main

int
main(int argc, char **argv)
{
  int c, flags = 0;
  char *attrname = 0;
  
  Pool *pool = pool_create();
  Repo *repo = repo_create(pool, "<stdin>");

  while ((c = getopt(argc, argv, "hn:")) >= 0)
    {
      switch(c)
	{
	case 'h':
	  usage(0);
	  break;
	case 'n':
	  attrname = optarg;
	  break;
	default:
	  usage(1);
	  break;
	}
    }
  if (repo_add_updateinfoxml(repo, stdin, flags))
    {
      fprintf(stderr, "updateinfoxml2solv: %s\n", pool_errstr(pool));
      exit(1);
    }
  tool_write(repo, 0, attrname);
  pool_free(pool);
  exit(0);
}
开发者ID:JackDunaway,项目名称:libsolv,代码行数:33,代码来源:updateinfoxml2solv.c

示例13: rxbuf_init

/**
 * Initialize pool of RX buffers.
 */
void
rxbuf_init(void)
{
	rxbuf_pagesize = compat_pagesize();
	rxpool = pool_create("RX buffers", rxbuf_pagesize,
		rxbuf_page_alloc, rxbuf_page_free, rxbuf_page_is_fragment);
}
开发者ID:MrJoe,项目名称:gtk-gnutella,代码行数:10,代码来源:rxbuf.c

示例14: main

int main(int argc, char **argv)
{
  pool p[1] = { pool_create() };
  
  int basis = (int) time(NULL);
  
  assert(argc == 1);
  
  random_init();
  int offset = rand() % 10000;
  
  uint32_t target = first_output_given_seed(basis - offset);
  
  // we have our target, just search!
  uint32_t check = basis;
  while (1)
  {
    if (first_output_given_seed(check) == target)
    {
      printf("ok\n");
      break;
    }
    check--;
  }
  
  p->finish(p);
  return 0;
}
开发者ID:ctz,项目名称:cryptopals,代码行数:28,代码来源:mcp22.c

示例15: pool_create

void *new_obj(pool_t *mpool, size_t sz)
{
    pool_t *mp = mpool;
    obj_t *ob = NULL;

    if (mp == NULL) {
        mp = pool_create(G_MPOOL_SIZE);
        if (mp == NULL) {
            return NULL;
        }

        ob = (obj_t *)pcalloc(mp, sz);
        if (ob == NULL) {
            pool_destroy(mp);
            return NULL;
        }   

        ob->new_mp_flag = 1;
    } else {
        ob = pcalloc(mp, sz);
        if (ob == NULL) {
            return NULL;
        }   

        ob->new_mp_flag = 0;
    }   

    ob->mpool = mp; 
    return ob;
}
开发者ID:joerong666,项目名称:hidb,代码行数:30,代码来源:obj.c


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