1 /* Fast lookup table abstraction implemented as a Guilmette Array
2 Copyright (C) 1989 Free Software Foundation, Inc.
3 written by Douglas C. Schmidt (schmidt@ics.uci.edu)
5 This file is part of GNU GPERF.
7 GNU GPERF is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
12 GNU GPERF is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU GPERF; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #include "boolarray.h"
25 /* Locally visible BOOL_ARRAY object. */
27 static BOOL_ARRAY bool_array;
29 /* Prints out debugging diagnostics. */
34 if (OPTION_ENABLED (option, DEBUG))
35 fprintf (stderr, "\ndumping boolean array information\niteration number = %d\nend of array dump\n",
36 bool_array.iteration_number);
37 free ((char *) bool_array.storage_array);
41 bool_array_init (size)
44 STORAGE_TYPE *xmalloc ();
45 bool_array.iteration_number = 1;
46 bool_array.size = size;
47 bool_array.storage_array = xmalloc (size * sizeof *bool_array.storage_array);
48 bzero (bool_array.storage_array, size * sizeof *bool_array.storage_array);
49 if (OPTION_ENABLED (option, DEBUG))
50 fprintf (stderr, "\nbool array size = %d, total bytes = %d\n",
51 bool_array.size, bool_array.size * sizeof *bool_array.storage_array);
58 if (bool_array.storage_array[index] == bool_array.iteration_number)
62 bool_array.storage_array[index] = bool_array.iteration_number;
67 /* Simple enough to reset, eh?! */
72 /* If we wrap around it's time to zero things out again! */
75 if (++bool_array.iteration_number == 0)
77 if (OPTION_ENABLED (option, DEBUG))
79 fprintf (stderr, "(re-initializing bool_array)...");
82 bool_array.iteration_number = 1;
83 bzero (bool_array.storage_array, bool_array.size * sizeof *bool_array.storage_array);
84 if (OPTION_ENABLED (option, DEBUG))
86 fprintf (stderr, "done\n");