tesseract  4.1.0
bitvec.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: bitvec.c
3  ** Purpose: Routines for manipulating bit vectors
4  ** Author: Dan Johnson
5  **
6  ** (c) Copyright Hewlett-Packard Company, 1988.
7  ** Licensed under the Apache License, Version 2.0 (the "License");
8  ** you may not use this file except in compliance with the License.
9  ** You may obtain a copy of the License at
10  ** http://www.apache.org/licenses/LICENSE-2.0
11  ** Unless required by applicable law or agreed to in writing, software
12  ** distributed under the License is distributed on an "AS IS" BASIS,
13  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ** See the License for the specific language governing permissions and
15  ** limitations under the License.
16  ******************************************************************************/
17 
18 /*-----------------------------------------------------------------------------
19  Include Files and Type Defines
20 -----------------------------------------------------------------------------*/
21 #include "bitvec.h"
22 
23 #include <cstdio>
24 
25 #include "emalloc.h"
26 
27 /*-----------------------------------------------------------------------------
28  Public Code
29 -----------------------------------------------------------------------------*/
30 /*---------------------------------------------------------------------------*/
43 BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) {
44  return (static_cast<BIT_VECTOR>(Erealloc(Vector,
45  sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits))));
46 } /* ExpandBitVector */
47 
48 
49 /*---------------------------------------------------------------------------*/
50 void FreeBitVector(BIT_VECTOR BitVector) {
63  if (BitVector) {
64  Efree(BitVector);
65  }
66 } /* FreeBitVector */
67 
68 
69 /*---------------------------------------------------------------------------*/
81 BIT_VECTOR NewBitVector(int NumBits) {
82  return (static_cast<BIT_VECTOR>(Emalloc(sizeof(uint32_t) *
83  WordsInVectorOfSize(NumBits))));
84 } /* NewBitVector */
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
void FreeBitVector(BIT_VECTOR BitVector)
Definition: bitvec.cpp:50
BIT_VECTOR NewBitVector(int NumBits)
Definition: bitvec.cpp:81
void Efree(void *ptr)
Definition: emalloc.cpp:45
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:38
uint32_t * BIT_VECTOR
Definition: bitvec.h:28
void * Emalloc(int Size)
Definition: emalloc.cpp:31
BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits)
Definition: bitvec.cpp:43