tesseract  4.0.0-1-g2a2b
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 #include "tprintf.h"
27 
28 /*-----------------------------------------------------------------------------
29  Public Code
30 -----------------------------------------------------------------------------*/
31 /*---------------------------------------------------------------------------*/
44 BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) {
45  return ((BIT_VECTOR) Erealloc(Vector,
46  sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits)));
47 } /* ExpandBitVector */
48 
49 
50 /*---------------------------------------------------------------------------*/
51 void FreeBitVector(BIT_VECTOR BitVector) {
64  if (BitVector) {
65  Efree(BitVector);
66  }
67 } /* FreeBitVector */
68 
69 
70 /*---------------------------------------------------------------------------*/
82 BIT_VECTOR NewBitVector(int NumBits) {
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
void Efree(void *ptr)
Definition: emalloc.cpp:45
uint32_t * BIT_VECTOR
Definition: bitvec.h:28
void FreeBitVector(BIT_VECTOR BitVector)
Definition: bitvec.cpp:51
BIT_VECTOR NewBitVector(int NumBits)
Definition: bitvec.cpp:82
BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits)
Definition: bitvec.cpp:44
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:38