diff --git a/block_access.cpp b/block_access.cpp index f959993..8ae1daf 100644 --- a/block_access.cpp +++ b/block_access.cpp @@ -936,19 +936,22 @@ int deleteRelCatEntry(recId relcat_recid, Attribute relcat_rec[6]) { relcat_header.numEntries = relcat_header.numEntries - 1; setHeader(&relcat_header, 4); unsigned char relcat_slotmap[20]; - getSlotmap(relcat_slotmap, 4); - relcat_slotmap[relcat_recid.slot] = SLOT_UNOCCUPIED; - setSlotmap(relcat_slotmap, 20, relcat_recid.block); - + getRecord(relcat_rec, 4, 0); relcat_rec[2].nval = relcat_rec[2].nval - 1; setRecord(relcat_rec, 4, 0); + getRecord(relcat_rec, 4, relcat_recid.slot); int no_of_attrs = relcat_rec[1].nval; + getRecord(relcat_rec, 4, 1); relcat_rec[2].nval = relcat_rec[2].nval - no_of_attrs; setRecord(relcat_rec, 4, 1); + getSlotmap(relcat_slotmap, 4); + relcat_slotmap[relcat_recid.slot] = SLOT_UNOCCUPIED; + setSlotmap(relcat_slotmap, 20, relcat_recid.block); + FILE *disk = fopen(&DISK_PATH[0], "rb+"); fseek(disk, (relcat_recid.block) * BLOCK_SIZE + HEADER_SIZE + SLOTMAP_SIZE_RELCAT_ATTRCAT + relcat_recid.slot * NO_OF_ATTRS_RELCAT_ATTRCAT * ATTR_SIZE, SEEK_SET);