#define XERR "memoryaccess"
#include "memoryaccess.ih"

// disconnects the connected block
// if erase is requested: 
//      kill all connected blocks 
//      kill the MemoryAccess object
// disconnect the MemoryAccess block

    // by memorybridge/destructor.cc

// static
void MemoryAccess::drop(MemoryAccess *ptr, bool erase)
{
    if (not s_loaded.empty())               // disconnect an activated block
        ptr->disconnect(s_loaded[ptr->d_idx]);  


    if (erase)
    {
        ptr->killBlocks();          // kill all data blocks
        killID(ptr->d_id);          // kill the MemoryAccess block itself
    }

    disconnect(ptr);                // disconnect the MemoryAccess block
}
