vfs: check userland buffers before reading them.
[haiku.git] / src / kits / debugger / util / BitBuffer.h
blob51354cbad71d5cedf123417a31e9539f334bcab0
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef BIT_BUFFER_H
6 #define BIT_BUFFER_H
9 #include <SupportDefs.h>
11 #include <Array.h>
14 class BitBuffer {
15 public:
16 BitBuffer();
17 ~BitBuffer();
19 bool AddBytes(const void* data, size_t size);
20 bool AddBits(const void* data, uint64 bitSize,
21 uint32 bitOffset = 0);
22 bool AddZeroBits(uint64 bitSize);
24 uint8* Bytes() const { return fBytes.Elements(); }
25 size_t Size() const { return fBytes.Size(); }
26 size_t BitSize() const
27 { return Size() * 8 - fMissingBits; }
29 private:
30 struct BitReader;
32 private:
33 Array<uint8> fBytes;
34 uint8 fMissingBits;
38 #endif // BIT_BUFFER_H