apr-pool 内存池测试用例
来源:互联网 发布:php网站破解工具 编辑:程序博客网 时间:2024/05/29 04:07
#include "stdafx.h"#include <new>#include "apr_pools.h"#pragma comment(lib,"libapr.lib")int _tmain(int argc, _TCHAR* argv[]){apr_pool_t *root;apr_pool_initialize();//初始化全局分配子(allocator),并为它设置mutext,以用于多线程环境,初始化全局池,指定全局分配子的owner是全局池apr_pool_create(&root,NULL);//创建根池(默认父池是全局池),根池生命期为进程生存期。分配子默认为全局分配子{apr_pool_t *child;apr_pool_create(&child,root);//创建子池,指定父池为root。分配子默认为父池分配子void *pBuff=apr_palloc(child,sizeof(int));//从子池分配内存int *pInt=new (pBuff) int(5);//随便举例下基于已分配内存后,面向对象构造函数的调用。printf("pInt=%d\n",*pInt);{typedef struct StudentInfo{char szName[20];bool nSex;};apr_pool_t *grandson;apr_pool_create(&grandson,root);void *pBuff2=apr_palloc(grandson,sizeof(StudentInfo));StudentInfo *pSI=new (pBuff2) StudentInfo();strcpy(pSI->szName,"zhangsan");pSI->nSex = 1;printf("Name=%s,sex=%d\n",pSI->szName,pSI->nSex); apr_pool_destroy(grandson);}apr_pool_destroy(child);//释放子池,将内存归还给分配子}apr_pool_destroy(root);//释放父池,apr_pool_terminate();//释放全局池,释放全局allocator,将内存归还给系统return 0;}
0 0
- apr-pool 内存池测试用例
- APR Pool内存管理策
- APR Pool内存管理策
- apr内存池
- [转]apr内存池
- apr内存池
- APR-内存池
- APR 内存池
- apr研究-内存池-1
- boost pool 内存池
- boost pool 内存池
- Boost.pool内存池
- 内存池 (Memory Pool)
- APR内存池的创建与销毁
- APR内存池的学习与实现
- boost 内存池Pool (转)
- 内存池(Memory Pool)基本概念
- boost的pool内存池
- AjaxControlToolkit中CalendarExtender日历控件的用法
- Informix触发器实例
- 数字金额转换成汉字
- 脏读,不可重复读,幻象读
- Informatica元数据库解析
- apr-pool 内存池测试用例
- android textview自动换行问题
- 二叉树的深度
- HDU4289-Control(最小割定理)
- curl访问不需要等待返回值的情况
- iOS UITextField属性全解
- Flash Builder 4:进程意外终止。 application descriptor not found 启动命令详细信息:
- oracle 使用leading, use_nl, rownum调优
- shell 中的单引号和双引号