tesseract  4.00.00dev
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  ** History: Thu Mar 15 10:37:27 1990, DSJ, Created.
6  **
7  ** (c) Copyright Hewlett-Packard Company, 1988.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  ******************************************************************************/
18 
19 /*-----------------------------------------------------------------------------
20  Include Files and Type Defines
21 -----------------------------------------------------------------------------*/
22 #include "bitvec.h"
23 
24 #include <stdio.h>
25 
26 #include "emalloc.h"
27 #include "tprintf.h"
28 
29 /*-----------------------------------------------------------------------------
30  Public Code
31 -----------------------------------------------------------------------------*/
32 /*---------------------------------------------------------------------------*/
47 BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) {
48  return ((BIT_VECTOR) Erealloc(Vector,
49  sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits)));
50 } /* ExpandBitVector */
51 
52 
53 /*---------------------------------------------------------------------------*/
54 void FreeBitVector(BIT_VECTOR BitVector) {
69  if (BitVector) {
70  Efree(BitVector);
71  }
72 } /* FreeBitVector */
73 
74 
75 /*---------------------------------------------------------------------------*/
89 BIT_VECTOR NewBitVector(int NumBits) {
90  return ((BIT_VECTOR) Emalloc(sizeof(uinT32) *
91  WordsInVectorOfSize(NumBits)));
92 } /* NewBitVector */
void FreeBitVector(BIT_VECTOR BitVector)
Definition: bitvec.cpp:54
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
void * Emalloc(int Size)
Definition: emalloc.cpp:47
uinT32 * BIT_VECTOR
Definition: bitvec.h:28
BIT_VECTOR NewBitVector(int NumBits)
Definition: bitvec.cpp:89
uint32_t uinT32
Definition: host.h:39
BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits)
Definition: bitvec.cpp:47
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:64
void Efree(void *ptr)
Definition: emalloc.cpp:79