summaryrefslogtreecommitdiff
path: root/buckets
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2013-01-26 20:41:15 +0000
committerStefan Fritsch <sf@apache.org>2013-01-26 20:41:15 +0000
commit0f9bec1ff8867743822886253e3e0a94a706714e (patch)
tree41f9d0959c73d69c03934f89c50bfc485ac146aa /buckets
parent9257d6c7a193f152b17448304ef2de9ae6db5a3f (diff)
downloadapr-0f9bec1ff8867743822886253e3e0a94a706714e.tar.gz
Add valgrind support
Teach valgrind about apr pools, allocators, and bucket allocators if --with-valgrind is passed to configure. This has less impact on program behavior and performance than compiling with complete pool-debugging. Even with valgrind support compiled in, the performance impact if not running under valgrind should be minimal. It may make sense to use pool-debugging together with valgrind support because pool-debugging does not help with allocators and bucket allocators. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1438957 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'buckets')
-rw-r--r--buckets/apr_buckets_alloc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/buckets/apr_buckets_alloc.c b/buckets/apr_buckets_alloc.c
index c73c7db35..7241a866b 100644
--- a/buckets/apr_buckets_alloc.c
+++ b/buckets/apr_buckets_alloc.c
@@ -18,6 +18,7 @@
#include "apr_buckets.h"
#include "apr_allocator.h"
+#include "apr_support.h"
#define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE)
@@ -102,7 +103,8 @@ APR_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(
list->freelist = NULL;
list->blocks = block;
block->first_avail += APR_ALIGN_DEFAULT(sizeof(*list));
-
+ APR_VALGRIND_NOACCESS(block->first_avail,
+ block->endp - block->first_avail);
return list;
}
@@ -121,18 +123,21 @@ APR_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list)
#endif
}
-APR_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size,
+APR_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t in_size,
apr_bucket_alloc_t *list)
{
node_header_t *node;
apr_memnode_t *active = list->blocks;
char *endp;
+ apr_size_t size;
- size += SIZEOF_NODE_HEADER_T;
+ size = in_size + SIZEOF_NODE_HEADER_T;
if (size <= SMALL_NODE_SIZE) {
if (list->freelist) {
node = list->freelist;
list->freelist = node->next;
+ APR_VALGRIND_UNDEFINED((char *)node + SIZEOF_NODE_HEADER_T,
+ SMALL_NODE_SIZE - SIZEOF_NODE_HEADER_T);
}
else {
endp = active->first_avail + SMALL_NODE_SIZE;
@@ -144,8 +149,11 @@ APR_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size,
list->blocks->next = active;
active = list->blocks;
endp = active->first_avail + SMALL_NODE_SIZE;
+ APR_VALGRIND_NOACCESS(active->first_avail,
+ active->endp - active->first_avail);
}
node = (node_header_t *)active->first_avail;
+ APR_VALGRIND_UNDEFINED(node, SMALL_NODE_SIZE);
node->alloc = list;
node->memnode = active;
node->size = SMALL_NODE_SIZE;
@@ -194,6 +202,7 @@ APR_DECLARE_NONSTD(void) apr_bucket_free(void *mem)
check_not_already_free(node);
node->next = list->freelist;
list->freelist = node;
+ APR_VALGRIND_NOACCESS(mem, SMALL_NODE_SIZE - SIZEOF_NODE_HEADER_T);
}
else {
apr_allocator_free(list->allocator, node->memnode);