apr 内存管理

时间:2023-03-09 15:32:21
apr 内存管理
//============================================================================
// Name : mytest.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
/*
#include <iostream>
using namespace std; int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
*/
/**
* apr tutorial sample code
* http://dev.ariel-networks.com/apr/
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include<iostream>
#include <apr_general.h>
using namespace std;
/**
* apr skeleton code
*/ #define LOCATE_SIZE 1000
int main(int argc, const char *argv[])
{
apr_status_t rv;
apr_pool_t *mp;
void *buf1;
void *buf2; //apr初始化
rv=apr_initialize();
if(rv!=APR_SUCCESS)
{
cout<<"创建失败"<<endl;
return -;
} //创建一个apr内存池
apr_pool_create(&mp,NULL);
//分配内存池
buf1= apr_palloc(mp,LOCATE_SIZE);
buf2=apr_palloc(mp,LOCATE_SIZE); //销毁内存池
apr_pool_destroy(mp);
//apr结束
apr_terminate();
cout<<buf1<<endl;//输出到有结果,所以应该是分配了地址了
cout<<buf2<<endl;//输出到有结果,所以应该是分配了地址了
cout<<"执行成功"<<endl;
return ;
}