File: getbits.cpp

package info (click to toggle)
unrar-nonfree 1%3A4.1.4-1%2Bdeb7u1
  • links: PTS
  • area: non-free
  • in suites: wheezy
  • size: 1,120 kB
  • sloc: cpp: 21,159; makefile: 32; sh: 10
file content (35 lines) | stat: -rw-r--r-- 816 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "rar.hpp"

BitInput::BitInput()
{
  // getbits attempts to read data from InAddr, InAddr+1, InAddr+2 positions.
  // So let's allocate two additional bytes for situation, when we need to
  // read only 1 byte from the last position of buffer and avoid a crash
  // from access to next 2 bytes, which contents we do not need.
  size_t BufSize=MAX_SIZE+2;
  InBuf=new byte[BufSize];

  // Ensure that we get predictable results when accessing bytes in area
  // not filled with read data.
  memset(InBuf,0,BufSize);
}


BitInput::~BitInput()
{
  delete[] InBuf;
}


void BitInput::faddbits(uint Bits)
{
  // Function wrapped version of inline addbits to save code size.
  addbits(Bits);
}


uint BitInput::fgetbits()
{
  // Function wrapped version of inline getbits to save code size.
  return(getbits());
}