+ PAGE_ALLOC_CLEAR(page);
+ }
+ else
+ PAGE_ALLOC_CLEAR(page);
+
+ // Update the free counts if the page was freed
+ if( !PAGE_ALLOC_TEST(page) )
+ {
+ int rangeID;
+ rangeID = MM_int_GetRangeID( PAddr );
+ giPhysRangeFree[ rangeID ] ++;
+ if( giPhysRangeFirst[rangeID] > page )
+ giPhysRangeFirst[rangeID] = page;
+ if( giPhysRangeLast[rangeID] < page )
+ giPhysRangeLast[rangeID] = page;
+ }
+
+ // If the bitmap entry is not -1, unset the bit in the super bitmap
+ if(gaMainBitmap[ page >> 6 ] + 1 != 0 ) {
+ gaSuperBitmap[page >> 12] &= ~(1LL << ((page >> 6) & 63));
+ }
+
+ #if TRACE_REF
+ Log("Page %P dereferenced (%i)", page << 12, MM_GetRefCount(page << 12));
+ #endif
+}
+
+int MM_GetRefCount( tPAddr PAddr )
+{
+ PAddr >>= 12;
+
+ if( PAddr > giMaxPhysPage ) return 0;
+
+ if( MM_GetPhysAddr( (tVAddr)&gaiPageReferences[PAddr] ) ) {
+ return gaiPageReferences[PAddr];
+ }
+
+ if( PAGE_ALLOC_TEST(PAddr) )
+ {
+ return 1;