dumb apr_pool question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

Am I correct to assume that a pool cannot be forcibly (prematurely)
freed? I was trying to understand apr_hash and wanted to free the memory
allocated for the keys and then try a apr_hash_get. You know, put it
through it's paces ;)

I read about apr_pool_clear:
"This does not actually free the memory, it just allows the pool to
re-use this memory for the next allocation."
but about apr_pool_destroy:
"This will actually free the memory"

However, when I run this simple program through valgrind, there are no
memory errors.

I suppose that the pool is keeping track of all it's allocations and if
something is still referenced, it will not free it.

I also suppose that "This will actually free the memory" is ambiguous:
https://apr.apache.org/docs/apr/1.6/group__apr__pools.html#ga54759954d2cba7cb649ab5680a33f9e3

https://apr.apache.org/docs/apr/trunk/group__apr__pools.html#ga54759954d2cba7cb649ab5680a33f9e3

Kind regards,

Simon




#include <stdio.h>
#include <linux/limits.h>
#include <apr-1.0/apr_pools.h>

char * test_destroy(void);

char * test_destroy(void)
{
    apr_pool_t * Crash = NULL;
    apr_pool_create(&Crash, NULL);
    char * String = apr_pcalloc(Crash, 4);
    strcpy(String, "txt");
    apr_pool_destroy(Crash);
    return String;
}

int main(int ArgCount, char * Arg[])
{
    apr_initialize();
    char * String = test_destroy();
    printf("String: %s\n", String);
    apr_terminate();
    return 0;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux