From f7a74210911b694e896ec1ae70a37303dd5a284b Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 11 Jun 2014 16:30:30 +0200 Subject: [PATCH] Configurable clearing of array in Bit_array_base Fixes #1177. --- repos/base/include/util/bit_array.h | 6 +++--- repos/os/include/os/packet_allocator.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/repos/base/include/util/bit_array.h b/repos/base/include/util/bit_array.h index e0a0f5f77d..fe4ef72fe6 100644 --- a/repos/base/include/util/bit_array.h +++ b/repos/base/include/util/bit_array.h @@ -92,14 +92,14 @@ namespace Genode { public: - Bit_array_base(unsigned bits, addr_t *addr) + Bit_array_base(unsigned bits, addr_t *addr, bool clear) : _bit_cnt(bits), _word_cnt(_bit_cnt / _BITS_PER_WORD), _words(addr) { if (!bits || bits % _BITS_PER_WORD) throw Invalid_bit_count(); - memset(_words, 0, sizeof(addr_t)*_word_cnt); + if (clear) memset(_words, 0, sizeof(addr_t)*_word_cnt); } /** @@ -144,7 +144,7 @@ namespace Genode { public: - Bit_array() : Bit_array_base(BITS, _array) { } + Bit_array() : Bit_array_base(BITS, _array, true) { } }; } diff --git a/repos/os/include/os/packet_allocator.h b/repos/os/include/os/packet_allocator.h index 5745d8430b..7b8a8ca584 100644 --- a/repos/os/include/os/packet_allocator.h +++ b/repos/os/include/os/packet_allocator.h @@ -76,7 +76,8 @@ class Genode::Packet_allocator : public Genode::Range_allocator _base = base; _bits = _md_alloc->alloc(_block_cnt(size)/8); _array = new (_md_alloc) Bit_array_base(_block_cnt(size), - (addr_t*)_bits); + (addr_t*)_bits, + true); return 0; }