/* Ivan Novick 2007 */ /* test apr pools functionality */ /* gcc -I/usr/include/apr-1.0 `apr-config --cppflags --cflags` -lapr-1 aprpool.c -o aprpooltest */ #include #include #include int main(int argc, char** argv) { apr_pool_t* my_pool; if (apr_initialize()) { fprintf(stderr, "could not initialize apr \n"); exit(1); } if (apr_pool_create(&my_pool, NULL) ) { fprintf(stderr, "could not create memory pool\n"); exit(1); } /* allocate some memory from the pool */ char* buffer1 = apr_palloc(my_pool, 1000); char* buffer2 = apr_palloc(my_pool, 2000); char* buffer3 = apr_palloc(my_pool, 4000); /* add back all the memory into the pool as available ... don't free */ apr_pool_clear(my_pool); /* allocate some memory from the pool */ buffer1 = apr_palloc(my_pool, 1000); buffer2 = apr_palloc(my_pool, 2000); buffer3 = apr_palloc(my_pool, 4000); /* free all the memory from the pool */ apr_pool_destroy(my_pool); /* to make library cleanup resources */ apr_terminate(); return 0; }