Skip to content

Commit

Permalink
#9 handled errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Jan 4, 2025
1 parent faefd4b commit 5a7e152
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kfile/slotted_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ func NewSlottedPage(pageSize int) *SlottedPage {
}

// Initialize header
sp.SetInt(0, pageSize) // Page size
sp.SetInt(4, PageHeaderSize) // Header size
sp.SetInt(8, 0) // Cell count
sp.SetInt(12, pageSize) // Free space pointer

err := sp.SetInt(0, pageSize) // Page size
err = sp.SetInt(4, PageHeaderSize) // Header size
err = sp.SetInt(8, 0) // Cell count
err = sp.SetInt(12, pageSize) // Free space pointer
if err != nil {
return nil
}
return sp
}

Expand Down Expand Up @@ -70,8 +72,11 @@ func (sp *SlottedPage) InsertCell(cell *Cell) error {
// Update header
sp.cellCount++
sp.freeSpace = newOffset
sp.SetInt(8, sp.cellCount)
sp.SetInt(12, sp.freeSpace)
err = sp.SetInt(8, sp.cellCount)
err = sp.SetInt(12, sp.freeSpace)
if err != nil {
return err
}

return nil
}
Expand Down

0 comments on commit 5a7e152

Please sign in to comment.