diff options
author | Maria Matejka <mq@ucw.cz> | 2021-12-01 13:02:44 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2021-12-01 13:04:52 +0100 |
commit | b50224a00351904f25a5105a98d56a62ed2c33a4 (patch) | |
tree | 8478675603fd2a91fb4f36f8ac2e4ffd0ac20cd3 /lib/resource.h | |
parent | 55ee9961e0d130bb16b22b7b5acffd815f266d63 (diff) | |
parent | f772afc525156498900770ffe5a98349df89a45c (diff) |
Merge branch 'master' into HEAD
Diffstat (limited to 'lib/resource.h')
-rw-r--r-- | lib/resource.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/resource.h b/lib/resource.h index 9d7dae69..b80ff8c6 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -2,6 +2,7 @@ * BIRD Resource Manager * * (c) 1998--1999 Martin Mares <mj@ucw.cz> + * (c) 2021 Maria Matejka <mq@jmq.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -11,6 +12,11 @@ #include "lib/lists.h" +struct resmem { + size_t effective; /* Memory actually used for data storage */ + size_t overhead; /* Overhead memory imposed by allocator strategies */ +}; + /* Resource */ typedef struct resource { @@ -26,11 +32,11 @@ struct resclass { void (*free)(resource *); /* Freeing function */ void (*dump)(resource *); /* Dump to debug output */ resource *(*lookup)(resource *, unsigned long); /* Look up address (only for debugging) */ - size_t (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */ + struct resmem (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */ }; /* Estimate of system allocator overhead per item, for memory consumtion stats */ -#define ALLOC_OVERHEAD 8 +#define ALLOC_OVERHEAD 16 /* Generic resource manipulation */ @@ -46,7 +52,7 @@ void resource_init(void); void rfree(void *); /* Free single resource */ void rdump(void *); /* Dump to debug output */ -size_t rmemsize(void *res); /* Return size of memory used by the resource */ +struct resmem rmemsize(void *res); /* Return size of memory used by the resource */ void rlookup(unsigned long); /* Look up address (only for debugging) */ void rmove(void *, pool *); /* Move to a different pool */ @@ -54,7 +60,7 @@ void *ralloc(pool *, struct resclass *); pool *rp_new(pool *, struct birdloop *loop, const char *); /* Create new pool */ void rp_free(pool *p, pool *parent); /* Free parent pool */ -size_t rp_memsize(pool *p); /* Return size of memory used by the pool */ +struct resmem rp_memsize(pool *p); /* Return size of memory used by the pool */ void rp_dump(pool *p); /* Dump pool to debug output */ extern pool root_pool; |