summaryrefslogtreecommitdiff
path: root/libhurd-mm/anonymous.c
diff options
context:
space:
mode:
authorneal <neal>2008-06-18 20:03:27 +0000
committerneal <neal>2008-06-18 20:03:27 +0000
commite1267d54fe059551c83766a36d022a2a3d7e4fd7 (patch)
treed415e9bea56fc4f3ed21490496f29520453b617d /libhurd-mm/anonymous.c
parent5c281f4aa051bc8c96479fcfe41ca23e23ba788c (diff)
2008-06-18 Neal H. Walfield <neal@gnu.org>
* anonymous.c (offset_compare): When calculating A_END, subtract one from A[1]. When calculating B_END, subtract one from B[1]. (mdestroy): Correctly calculate the bounds. Detach the node from the tree.
Diffstat (limited to 'libhurd-mm/anonymous.c')
-rw-r--r--libhurd-mm/anonymous.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libhurd-mm/anonymous.c b/libhurd-mm/anonymous.c
index fc23db7..a58fa07 100644
--- a/libhurd-mm/anonymous.c
+++ b/libhurd-mm/anonymous.c
@@ -51,13 +51,13 @@ offset_compare (const uintptr_t *a, const uintptr_t *b)
{
bool have_range = (*a & 1) || (*b & 1);
if (unlikely (have_range))
- /* If the least significant bit is set, then we the following word
- is the length. In this case, we are interested in overlap. */
+ /* If the least significant bit is set, then the following word is
+ the length. In this case, we are interested in overlap. */
{
uintptr_t a_start = *a & ~1;
- uintptr_t a_end = a_start + ((*a & 1) ? a[1] : 0);
+ uintptr_t a_end = a_start + ((*a & 1) ? a[1] - 1 : 0);
uintptr_t b_start = *b & ~1;
- uintptr_t b_end = b_start + ((*b & 1) ? b[1] : 0);
+ uintptr_t b_end = b_start + ((*b & 1) ? b[1] - 1 : 0);
if (a_end < b_start)
return -1;
@@ -353,6 +353,8 @@ mdestroy (struct map *map)
= hurd_btree_storage_desc_find (storage_descs, &offset[0]);
if (next)
{
+ int count = 0;
+
/* We destory STORAGE_DESC. Grab its pervious pointer
first. */
struct storage_desc *prev = hurd_btree_storage_desc_prev (next);
@@ -365,20 +367,25 @@ mdestroy (struct map *map)
next = (dir == 0 ? hurd_btree_storage_desc_next (storage_desc)
: hurd_btree_storage_desc_prev (storage_desc));
- if (storage_desc->offset < map->region.start
+ if (storage_desc->offset < map->offset
|| (storage_desc->offset
- > map->region.start + map->region.length - 1))
+ > map->offset + map->region.length - 1))
break;
storage_free (storage_desc->storage, false);
+ hurd_btree_storage_desc_detach (storage_descs, storage_desc);
#ifndef NDEBUG
/* When reallocating, we expect that the node field is 0.
libhurd-btree asserts this, so make it so. */
memset (storage_desc, 0, sizeof (struct storage_desc));
#endif
storage_desc_free (storage_desc);
+
+ count ++;
}
+
+ debug (5, "Freed %d pages", count);
}
/* Free the map area. Should we also free the staging area? */