/* Functions to support general ended bitmaps.
- Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU CC.
bitmap_element bitmap_zero; /* An element of all zero bits. */
bitmap_element *bitmap_free; /* Freelist of bitmap elements. */
-static void bitmap_element_free PROTO((bitmap, bitmap_element *));
-static bitmap_element *bitmap_element_allocate PROTO((void));
-static int bitmap_element_zerop PROTO((bitmap_element *));
-static void bitmap_element_link PROTO((bitmap, bitmap_element *));
-static bitmap_element *bitmap_find_bit PROTO((bitmap, unsigned int));
+static void bitmap_element_free PARAMS ((bitmap, bitmap_element *));
+static bitmap_element *bitmap_element_allocate PARAMS ((void));
+static int bitmap_element_zerop PARAMS ((bitmap_element *));
+static void bitmap_element_link PARAMS ((bitmap, bitmap_element *));
+static bitmap_element *bitmap_find_bit PARAMS ((bitmap, unsigned int));
\f
/* Free a bitmap element */
bitmap from2;
enum bitmap_bits operation;
{
+#define HIGHEST_INDEX (unsigned int) ~0
+
bitmap_element *from1_ptr = from1->first;
bitmap_element *from2_ptr = from2->first;
- unsigned int indx1 = (from1_ptr) ? from1_ptr->indx : -1;
- unsigned int indx2 = (from2_ptr) ? from2_ptr->indx : -1;
+ unsigned int indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
+ unsigned int indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
bitmap_element *to_ptr = to->first;
bitmap_element *from1_tmp;
bitmap_element *from2_tmp;
from1_tmp = from1_ptr;
from2_tmp = from2_ptr;
from1_ptr = from1_ptr->next;
- indx1 = (from1_ptr) ? from1_ptr->indx : -1;
+ indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
from2_ptr = from2_ptr->next;
- indx2 = (from2_ptr) ? from2_ptr->indx : -1;
+ indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
}
else if (indx1 < indx2)
{
from1_tmp = from1_ptr;
from2_tmp = &bitmap_zero;
from1_ptr = from1_ptr->next;
- indx1 = (from1_ptr) ? from1_ptr->indx : -1;
+ indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
}
else
{
from1_tmp = &bitmap_zero;
from2_tmp = from2_ptr;
from2_ptr = from2_ptr->next;
- indx2 = (from2_ptr) ? from2_ptr->indx : -1;
+ indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
}
/* Find the appropriate element from TO. Begin by discarding
changed = 1;
to_tmp = to_ptr;
to_ptr = to_ptr->next;
- to_tmp = bitmap_free;
+ to_tmp->next = bitmap_free;
bitmap_free = to_tmp;
}
if (to_ptr && to_ptr->indx == indx)
to_tmp->indx = indx;
bitmap_element_link (to, to_tmp);
}
+ else
+ {
+ to_tmp->next = bitmap_free;
+ bitmap_free = to_tmp;
+ }
}
/* If we have elements of TO left over, free the lot. */