zoukankan      html  css  js  c++  java
  • 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 -1;
        }
    
        //创建一个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 0;
    }
    View Code
  • 相关阅读:
    好玩的贪吃蛇小游戏,有趣极了!
    vue的多选框存储值操作
    vue和jquery嵌套实现异步ajax通信
    vue的组件学习———做一个简易机器人
    vue监听属性完成首字母大小写转换
    Vue多选框的绑定
    Vue.js的简介、属性
    MySQL数据库(5)
    DRF的json web token方式完成用户认证
    DRF跨域问题
  • 原文地址:https://www.cnblogs.com/yufenghou/p/3200093.html
Copyright © 2011-2022 走看看