Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / gperf / src / Bool_Array.cpp
blobe2f206b134a27c0c2f2454f169ed1aa730db710b
1 // -*- C++ -*-
3 // Fast lookup table abstraction implemented as an Iteration Number Array
5 /**
6 * Copyright (C) 1989 Free Software Foundation, Inc.
7 * written by Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
9 * This file is part of GNU GPERF.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "Bool_Array.h"
27 #include "ace/OS_NS_string.h"
28 #include "ace/OS_Memory.h"
30 // Prints out debugging diagnostics.
32 Bool_Array::~Bool_Array ()
34 if (option[DEBUGGING])
35 ACE_DEBUG ((LM_DEBUG,
36 "\ndumping boolean array information\n"
37 "size = %u\niteration number = %u\nend of array dump\n",
38 size_,
39 generation_number_));
40 delete [] this->storage_array_;
43 Bool_Array::Bool_Array ()
44 : storage_array_ (0),
45 generation_number_ (0),
46 size_ (0)
50 int
51 Bool_Array::open (u_long s)
53 this->generation_number_ = 1;
54 this->size_ = s;
56 ACE_NEW_RETURN (storage_array_,
57 u_long[s],
58 -1);
60 ACE_OS::memset (storage_array_,
62 s * sizeof *storage_array_);
64 if (option[DEBUGGING])
65 ACE_DEBUG ((LM_DEBUG,
66 "\nbool array size = %u, total bytes = %u\n",
67 size_,
68 size_ * (int) sizeof *storage_array_));
69 return 0;
72 int
73 Bool_Array::find (u_long slot)
75 if (storage_array_[slot] == generation_number_)
76 return 1;
77 else
79 storage_array_[slot] = generation_number_;
80 return 0;
84 void
85 Bool_Array::reset ()
87 if (++generation_number_ == 0)
89 if (option[DEBUGGING])
90 ACE_DEBUG ((LM_DEBUG,
91 "(re-initializing bool_array)..."));
93 this->generation_number_ = 1;
94 ACE_OS::memset (storage_array_,
96 size_ * sizeof *storage_array_);
97 if (option[DEBUGGING])
98 ACE_DEBUG ((LM_DEBUG,
99 "done\n"));