- // Clear the range
- memset(
- &gaiPageReferences[ ent->Base >> 12 ],
- 0,
- (ent->Size>>12)*sizeof(*gaiPageReferences)
- );
+
+ // Main bitmap
+ base = ent->Base >> 12;
+ size = ent->Size >> 12;
+
+ if(base & 63) {
+ Uint64 val = -1 << (base & 63);
+ gaMainBitmap[base / 64] &= ~val;
+ size -= (base & 63);
+ base += 64 - (base & 63);
+ }
+ memset( &gaMainBitmap[base / 64], 0, size/8 );
+ if( size & 7 ) {
+ Uint64 val = -1 << (size & 7);
+ val <<= (size/8)&7;
+ gaMainBitmap[base / 64] &= ~val;
+ }
+
+ // Super Bitmap
+ base = ent->Base >> 12;
+ size = ent->Size >> 12;
+ size = (size + (base & 63) + 63) >> 6;
+ base = base >> 6;
+ if(base & 63) {
+ Uint64 val = -1 << (base & 63);
+ gaSuperBitmap[base / 64] &= ~val;
+ size -= (base & 63);
+ base += 64 - (base & 63);
+ }
+ memset( &gaSuperBitmap[base / 64], 0, size/8 );
+ if( size & 7 ) {
+ Uint64 val = -1 << (size & 7);
+ val <<= (size/8)&7;
+ gaSuperBitmap[base / 64] &= ~val;
+ }