原文地址:http://blog.csdn.net/sunlion81/article/details/8818462
-
#include
-
#include
-
#include // for pj_init.
-
-
#define THIS_FILE "main.c"
-
-
int main(int argc, char** argv)
-
{
-
pj_status_t status;
-
pj_caching_pool ch_pool;
-
-
-
status = pj_init();
-
if (status != PJ_SUCCESS)
-
{
-
char errmsg[PJ_ERR_MSG_SIZE];
-
pj_strerror(status, errmsg, sizeof(errmsg));
-
PJ_LOG(1,(THIS_FILE, "%s: %s [status=%d]", pj_init, errmsg, status));
-
return -1;
-
}
-
-
-
pj_caching_pool_init(&ch_pool, NULL, 1024*1024);
-
-
-
{
-
pj_pool_t *pool;
-
pj_pool_factory *factory =&ch_pool.factory;
-
-
-
pool = pj_pool_create(factory, "pjlib_demo", 4*1024, 4*1024, NULL);
-
if (pool == NULL)
-
{
-
PJ_LOG(1,(THIS_FILE, "Error:pj_pool_create is NULL."));
-
return PJ_ENOMEM;
-
}
-
-
-
{
-
int i;
-
for (i=0; i<1000; i++)
-
{
-
void* p;
-
p = pj_pool_alloc(pool, (pj_rand()+1) % 512);
-
}
-
-
-
}
-
-
-
pj_pool_release(pool);
-
}
-
-
-
pj_caching_pool_destroy(&ch_pool);
-
-
-
pj_shutdown();
-
-
return 0;
-
}
阅读(1005) | 评论(0) | 转发(0) |