aboutsummaryrefslogtreecommitdiff
path: root/nscd/mem.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-29 00:17:57 +0000
committerUlrich Drepper <drepper@redhat.com>2009-01-29 00:17:57 +0000
commitfd537e535fe9f4d2b0286cf7a7242ef1e6775e67 (patch)
tree2eed5f293901fe55fc170dd02dd120f92acf1ece /nscd/mem.c
parent31d322a214386b20bb82c06d0c436bd0f0e80236 (diff)
downloadglibc-fd537e535fe9f4d2b0286cf7a7242ef1e6775e67.zip
glibc-fd537e535fe9f4d2b0286cf7a7242ef1e6775e67.tar.gz
glibc-fd537e535fe9f4d2b0286cf7a7242ef1e6775e67.tar.bz2
[BZ #9750]
* nscd/mem.c (gc): Use alloca_count to get the real stack usage. * include/alloca.h (alloca_account): Define. * sysdeps/x86_64/stackinfo.h (stackinfo_get_sp): Define. (stackinfo_sub_sp): Define.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index 5f4c4dd..7f3ea06 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -134,12 +134,11 @@ gc (struct database_dyn *db)
stack_used = 0;
size_t nmark = (db->head->first_free / BLOCK_ALIGN + BITS - 1) / BITS;
size_t memory_needed = nmark * sizeof (BITMAP_T);
- if (stack_used + memory_needed <= MAX_STACK_USE)
+ if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1))
{
- mark = (BITMAP_T *) alloca (memory_needed);
+ mark = (BITMAP_T *) alloca_account (memory_needed, stack_used);
mark_use_malloc = false;
memset (mark, '\0', memory_needed);
- stack_used += memory_needed;
}
else
{
@@ -153,19 +152,17 @@ gc (struct database_dyn *db)
struct hashentry **he;
struct hashentry **he_data;
bool he_use_malloc;
- if (stack_used + memory_needed <= MAX_STACK_USE)
+ if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1))
{
- he = alloca (db->head->nentries * sizeof (struct hashentry *));
- he_data = alloca (db->head->nentries * sizeof (struct hashentry *));
+ he = alloca_account (memory_needed, stack_used);
he_use_malloc = false;
- stack_used += memory_needed;
}
else
{
he = xmalloc (memory_needed);
- he_data = &he[db->head->nentries];
he_use_malloc = true;
}
+ he_data = &he[db->head->nentries];
size_t cnt = 0;
for (size_t idx = 0; idx < db->head->module; ++idx)
@@ -373,11 +370,9 @@ gc (struct database_dyn *db)
ref_t disp = off_alloc - off_free;
struct moveinfo *new_move;
- if (stack_used + sizeof (*new_move) <= MAX_STACK_USE)
- {
- new_move = alloca (sizeof (*new_move));
- stack_used += sizeof (*new_move);
- }
+ if (__builtin_expect (stack_used + sizeof (*new_move) <= MAX_STACK_USE,
+ 1))
+ new_move = alloca_account (sizeof (*new_move), stack_used);
else
new_move = obstack_alloc (&ob, sizeof (*new_move));
new_move->from = db->data + off_alloc;