本文整理汇总了C++中pool_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ pool_destroy函数的具体用法?C++ pool_destroy怎么用?C++ pool_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pool_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
}
示例3: 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);
}
示例4: hashtable_destroy
/**
* @brief Dispose of a hash table
*
* This function deletes all the entries from the given hash table and
* then destroys the hash table.
*
* @param[in,out] ht Pointer to the hash table. After calling
* this function, the memory pointed to by ht
* must not be accessed in any way.
* @param[in] free_func Function to free entries as they are
* deleted
*
* @return HASHTABLE_SUCCESS on success, other things on failure
*/
hash_error_t
hashtable_destroy(struct hash_table *ht,
int (*free_func)(struct gsh_buffdesc,
struct gsh_buffdesc))
{
size_t index = 0;
hash_error_t hrc = HASHTABLE_SUCCESS;
hrc = hashtable_delall(ht, free_func);
if (hrc != HASHTABLE_SUCCESS)
goto out;
for (index = 0; index < ht->parameter.index_size; ++index) {
if (ht->partitions[index].cache) {
gsh_free(ht->partitions[index].cache);
ht->partitions[index].cache = NULL;
}
PTHREAD_RWLOCK_destroy(&(ht->partitions[index].lock));
}
pool_destroy(ht->node_pool);
pool_destroy(ht->data_pool);
gsh_free(ht);
out:
return hrc;
}
示例5: nfs_node_done
/*
* Free resources previously allocated in nfs_node_reinit().
*/
void
nfs_node_done(void)
{
pool_destroy(&nfs_node_pool);
pool_destroy(&nfs_vattr_pool);
workqueue_destroy(nfs_sillyworkq);
}
示例6: ext2fs_done
void
ext2fs_done(void)
{
ufs_done();
pool_destroy(&ext2fs_inode_pool);
pool_destroy(&ext2fs_dinode_pool);
}
示例7: scene_destroy
void scene_destroy(Scene* scene) {
cpSpaceFree(scene->space);
// entities has to be first, because of relation with components
pool_destroy(scene->entities);
pool_destroy(scene->transforms);
pool_destroy(scene->scripts);
pool_destroy(scene->sprites);
free(scene);
}
示例8: bacstack_session_destroy
int bacstack_session_destroy(bacstack_session_t *session)
{
return 1
&& rwlock_destroy(&session->routetable_lock)
&& bacstack_routetable_destroy(&session->routetable)
&& pool_destroy(&session->message_pool)
&& pool_destroy(&session->proc_pool)
&& bacdl_server_destroy(&session->dl_server)
&& thread_destroy(&session->msg_proc_thread)
&& thread_destroy(&session->dl_accept_thread)
&& thread_destroy(&session->dl_receive_thread);
}
示例9: glw_fini
void
glw_fini(glw_root_t *gr)
{
glw_text_bitmap_fini(gr);
rstr_release(gr->gr_default_font);
glw_tex_fini(gr);
free(gr->gr_skin);
glw_fini_settings(gr);
pool_destroy(gr->gr_token_pool);
pool_destroy(gr->gr_clone_pool);
prop_courier_destroy(gr->gr_courier);
hts_mutex_destroy(&gr->gr_mutex);
}
示例10: upload_speed
void upload_speed(char* dest_server_ip,char* interface_name,char* vist_domain)
{
int i;
int loop = HTTP_SEND_NUM;
struct download_post_info info[HTTP_SEND_NUM];
/*delay time */
struct timeval starttime,endtime;
/*fill struct for post */
for(i=0;i<loop;i++){
fill_upload_request(info[i].post_string,vist_domain);
strncpy(info[i].server_ip,dest_server_ip,IPV4_SIZE);
strncpy(info[i].interface,interface_name,MAX_NAME_LEN);
}
gettimeofday(&starttime,0);
for(i=0;i<loop;i++){
pool_add_worker(file_upload,&info[i]);
}
while(1){
usleep(1000);
//IK_APP_DEBUG_LOG("pool->cur_queue_size == %d\n",pool->cur_queue_size);
if(pool->cur_queue_size == 0){
pool_destroy();
gettimeofday(&endtime,0);
double timeuse = (1000000*(endtime.tv_sec - starttime.tv_sec) + endtime.tv_usec - starttime.tv_usec)/1000000;
double result = (sum_send_lens / timeuse / (1024 * 1024));
printf("sum_lens: %lld byte | time_use: %f s | speed : %.2fMB\n",sum_send_lens,timeuse,result);
break;
}
}
}
示例11: HacheTableDestroy
/*
* Deallocates a HacheTable object (created by HacheTableCreate).
*
* The deallocate_data parameter is a boolean to indicate whether the
* data attached to the hash table should also be free()d. DO NOT USE
* this if the HacheData attached was not a pointer allocated using
* malloc().
*/
void HacheTableDestroy(HacheTable *h, int deallocate_data) {
int i;
if (!h)
return;
//HacheTableRefInfo(h, stdout);
for (i = 0; i < h->nbuckets; i++) {
HacheItem *hi = h->bucket[i], *next = NULL;
for (hi = h->bucket[i]; hi; hi = next) {
assert(hi->h == h);
next = hi->next;
HacheItemDestroy(h, hi, deallocate_data);
}
}
if (h->hi_pool) pool_destroy(h->hi_pool);
if (h->bucket)
free(h->bucket);
if (h->ordering)
free(h->ordering);
free(h);
}
示例12: Shutdown
static void Shutdown()
{
debug_printf(L"H_MGR| shutdown. any handle frees after this are leaks!\n");
// objects that store handles to other objects are destroyed before their
// children, so the subsequent forced destruction of the child here will
// raise a double-free warning unless we ignore it. (#860, #915, #920)
ignoreDoubleFree = true;
H_ScopedLock s;
// forcibly close all open handles
for(HDATA* hd = (HDATA*)hpool.da.base; hd < (HDATA*)(hpool.da.base + hpool.da.pos); hd = (HDATA*)(uintptr_t(hd)+hpool.el_size))
{
// it's already been freed; don't free again so that this
// doesn't look like an error.
if(hd->key == 0)
continue;
// disable caching; we need to release the resource now.
hd->keep_open = 0;
hd->refs = 0;
h_free_hd(hd);
}
pool_destroy(&hpool);
}
示例13: test_getset_parameter_node_value
static void test_getset_parameter_node_value (abts_case *tc, void *data)
{
cwmp_t * c = (cwmp_t*)data;
parameter_node_t * param;
char * name = "InternetGatewayDevice.DeviceInfo.SoftwareVersion";
char * retval;
char * value ;
pool_t * pool = pool_create(POOL_DEFAULT_SIZE);
FUNCTION_TRACE();
param = cwmp_get_parameter_path_node(c->root, name);
ASSERT_NOTNULL(param);
value = "V1.3.x";
cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
retval = cwmp_data_get_parameter_value(c, param, name, pool);
printf("retval ------------------is %s\n", retval);
ASSERT_STR_EQ(value, retval);
value = "V1.4.x";
cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
retval = cwmp_data_get_parameter_value(c, param, name, pool);
ASSERT_STR_EQ(value, retval);
pool_destroy(pool);
}
示例14: handle_request_socket
void handle_request_socket(http_conf *g , struct epoll_event *evfd ) {
epoll_extra_data_t * epoll_data = (epoll_extra_data_t *)evfd->data.ptr;
http_connect_t *con = (http_connect_t *) epoll_data->ptr;
if(con->in == NULL) {
//accept_handler(g, con, evfd);
epoll_edit_fd(g->epfd, evfd, EPOLL_W);
return ;
//epoll_del_fd(g->epfd, evfd);
}
while(con->next_handle != NULL) {
int ret = con->next_handle(con);
if(ret == DONE) {
if(con->in->execute_file != NULL && con->in->execute_file->len > 0) {
char *shPath = (char *)palloc(con->p, sizeof(char)*con->in->execute_file->len +1);
strncpy(shPath, con->in->execute_file->ptr, con->in->execute_file->len);
ds_log(con, " [send execute sh command:]", LOG_LEVEL_DEFAULT);
send_execute_sh_cmd(con, g);
}
con->next_handle = NULL;
epoll_del_fd(g->epfd, evfd);
close(con->fd);
ds_log(con, " [END] ", LOG_LEVEL_DEFAULT);
pool_destroy(con->p);
//handle_request_destory(g, evfd);
}else if(ret == CONTINUE) {
break;
}
}
}
示例15: TestEntries
static void TestEntries()
{
const int SZ = 4;
const int ALGN = 4;
size_t size[SZ] = {8, 8000, 9000, 100*1024};
size_t algn[ALGN] = {8, 64, 4*1024, 8*1024*1024};
rml::MemPoolPolicy pol(getGranMem, putGranMem);
currGranularity = 1; // not check granularity in the test
rml::MemoryPool *pool;
pool_create_v1(0, &pol, &pool);
for (int i=0; i<SZ; i++)
for (int j=0; j<ALGN; j++) {
char *p = (char*)pool_aligned_malloc(pool, size[i], algn[j]);
ASSERT(p && 0==((uintptr_t)p & (algn[j]-1)), NULL);
memset(p, j, size[i]);
size_t curr_algn = algn[rand() % ALGN];
size_t curr_sz = size[rand() % SZ];
char *p1 = (char*)pool_aligned_realloc(pool, p, curr_sz, curr_algn);
ASSERT(p1 && 0==((uintptr_t)p1 & (curr_algn-1)), NULL);
ASSERT(memEqual(p1, min(size[i], curr_sz), j), NULL);
memset(p1, j+1, curr_sz);
size_t curr_sz1 = size[rand() % SZ];
char *p2 = (char*)pool_realloc(pool, p1, curr_sz1);
ASSERT(p2, NULL);
ASSERT(memEqual(p2, min(curr_sz1, curr_sz), j+1), NULL);
pool_free(pool, p2);
}
pool_destroy(pool);
}