cache.c
//Should only be called for freed blocks (just removed the access queue)
Should only be called for freed blocks (just removed the access queue)
Should only be called for freed blocks ( just removed the access queue )
bool removeBlockMapping(activity_table_t* hostTable, block_list_node_t* toRemove) {
    if(!hostTable) {
        fprintf(stderr, "The hosting activity table has no been properly initialized\n");
        return false;
    }
    if(!toRemove) {
        fprintf(stderr, "You cannot remove a mapping for a NULL block.\n");
        return false;
    }
    uint32_t targetSector = lookupMapping(toRemove->block->id);
    block_mapping_node_t* sentinel = hostTable->ActiveBlockMap[targetSector];
    block_mapping_node_t* last = NULL;
    while(sentinel) {
        if(sentinel->mappedBlockNode == toRemove) {
            if(last) {
                last->next = sentinel->next;
            }
            else{
                hostTable->ActiveBlockMap[targetSector] = sentinel->next;
            }
            if(!destroyMappingNode(sentinel)) {
                return false; 
            }
            return true;
        }
        sentinel = sentinel->next;
    }
    if(sentinel)
    fprintf(stderr, "Block node was not mapped in the table.\n");
    return false;
}
bool removeBlockMapping ( activity_table_t * hostTable , block_list_node_t * toRemove ) { if ( ! hostTable ) { fprintf ( stderr , " \n " ) ; return false ; } if ( ! toRemove ) { fprintf ( stderr , " \n " ) ; return false ; } uint32_t targetSector = lookupMapping ( toRemove -> block -> id ) ; block_mapping_node_t * sentinel = hostTable -> ActiveBlockMap [ targetSector ] ; block_mapping_node_t * last = NULL ; while ( sentinel ) { if ( sentinel -> mappedBlockNode == toRemove ) { if ( last ) { last -> next = sentinel -> next ; } else { hostTable -> ActiveBlockMap [ targetSector ] = sentinel -> next ; } if ( ! destroyMappingNode ( sentinel ) ) { return false ; } return true ; } sentinel = sentinel -> next ; } if ( sentinel ) fprintf ( stderr , " \n " ) ; return false ; }
Should only be called for freed blocks (just removed the access queue)
Should only be called for freed blocks ( just removed the access queue )
//destructor will print err msg