projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Redo makefiles.
[pintos-anon]
/
src
/
lib
/
bitmap.c
diff --git
a/src/lib/bitmap.c
b/src/lib/bitmap.c
index c5ca38ab43d182ce75a32d1d42bbf3725143dba4..eb18a4963924187b66d6bb17f6aef8a2ff2e8970 100644
(file)
--- a/
src/lib/bitmap.c
+++ b/
src/lib/bitmap.c
@@
-3,9
+3,9
@@
#include <limits.h>
#include "debug.h"
#include "lib.h"
#include <limits.h>
#include "debug.h"
#include "lib.h"
-#include "malloc.h"
+#include "
threads/
malloc.h"
#ifdef FILESYS
#ifdef FILESYS
-#include "file.h"
+#include "file
sys/file
.h"
#endif
\f
/* Number of bits in an element. */
#endif
\f
/* Number of bits in an element. */
@@
-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. */