tesseract  4.0.0-1-g2a2b
bitvec.cpp File Reference
#include "bitvec.h"
#include <cstdio>
#include "emalloc.h"
#include "tprintf.h"

Go to the source code of this file.

Functions

BIT_VECTOR ExpandBitVector (BIT_VECTOR Vector, int NewNumBits)
 
void FreeBitVector (BIT_VECTOR BitVector)
 
BIT_VECTOR NewBitVector (int NumBits)
 

Function Documentation

◆ ExpandBitVector()

BIT_VECTOR ExpandBitVector ( BIT_VECTOR  Vector,
int  NewNumBits 
)

This routine uses realloc to increase the size of the specified bit vector.

Globals:

  • none
Parameters
Vectorbit vector to be expanded
NewNumBitsnew size of bit vector
Returns
New expanded bit vector.

Definition at line 44 of file bitvec.cpp.

44  {
45  return ((BIT_VECTOR) Erealloc(Vector,
46  sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits)));
47 } /* ExpandBitVector */
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
uint32_t * BIT_VECTOR
Definition: bitvec.h:28
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:38

◆ FreeBitVector()

void FreeBitVector ( BIT_VECTOR  BitVector)

This routine frees a bit vector. It also decrements the global counter that keeps track of the number of bit vectors allocated. If BitVector is nullptr, then the count is printed to stderr.

Globals:

  • BitVectorCount count of number of bit vectors allocated
Parameters
BitVectorbit vector to be freed

Definition at line 51 of file bitvec.cpp.

51  {
64  if (BitVector) {
65  Efree(BitVector);
66  }
67 } /* FreeBitVector */
void Efree(void *ptr)
Definition: emalloc.cpp:45

◆ NewBitVector()

BIT_VECTOR NewBitVector ( int  NumBits)

Allocate and return a new bit vector large enough to hold the specified number of bits.

Globals:

  • BitVectorCount number of bit vectors allocated
Parameters
NumBitsnumber of bits in new bit vector
Returns
New bit vector.

Definition at line 82 of file bitvec.cpp.

82  {
83  return ((BIT_VECTOR) Emalloc(sizeof(uint32_t) *
84  WordsInVectorOfSize(NumBits)));
85 } /* NewBitVector */
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
void * Emalloc(int Size)
Definition: emalloc.cpp:31
uint32_t * BIT_VECTOR
Definition: bitvec.h:28