projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b6f0a18
)
Handle bit_cnt of 0 properly.
author
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:29:42 +0000
(08:29 +0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:29:42 +0000
(08:29 +0000)
src/lib/bitmap.c
patch
|
blob
|
history
diff --git
a/src/lib/bitmap.c
b/src/lib/bitmap.c
index c5ca38ab43d182ce75a32d1d42bbf3725143dba4..8357d2e1fe2f951a6713efb7572b065e3eb3bb2a 100644
(file)
--- a/
src/lib/bitmap.c
+++ b/
src/lib/bitmap.c
@@
-101,9
+101,12
@@
bitmap_set_all (struct bitmap *b, bool value)
ASSERT (b != NULL);
ASSERT (b != NULL);
- for (i = 0; i < elem_cnt (b); i++)
- b->bits[i] = value ? (elem_type) -1 : 0;
- b->bits[elem_cnt (b) - 1] &= last_mask (b);
+ if (b->bit_cnt > 0)
+ {
+ for (i = 0; i < elem_cnt (b); i++)
+ b->bits[i] = value ? (elem_type) -1 : 0;
+ b->bits[elem_cnt (b) - 1] &= last_mask (b);
+ }
}
/* Sets the bit numbered IDX in B to true. */
}
/* Sets the bit numbered IDX in B to true. */
@@
-274,8
+277,11
@@
bitmap_file_size (const struct bitmap *b)
void
bitmap_read (struct bitmap *b, struct file *file)
{
void
bitmap_read (struct bitmap *b, struct file *file)
{
- file_read_at (file, b->bits, byte_cnt (b), 0);
- b->bits[elem_cnt (b) - 1] &= last_mask (b);
+ if (b->bit_cnt > 0)
+ {
+ file_read_at (file, b->bits, byte_cnt (b), 0);
+ b->bits[elem_cnt (b) - 1] &= last_mask (b);
+ }
}
/* Writes FILE to B, ignoring errors. */
}
/* Writes FILE to B, ignoring errors. */