Skip to content

Commit addacac

Browse files
committed
feat(silo): allocate new buffer with new - this handles case where allocation fails
1 parent f547e9f commit addacac

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/silo/storage/buffer/page.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Page {
1313
public:
1414
uint8_t* buffer;
1515

16-
Page() { buffer = reinterpret_cast<uint8_t*>(malloc(PAGE_SIZE)); }
16+
Page() { buffer = new uint8_t[PAGE_SIZE]; }
1717

1818
Page(Page&& other) noexcept
1919
: buffer(other.buffer) {
@@ -26,9 +26,7 @@ class Page {
2626
}
2727

2828
~Page() {
29-
if (buffer) {
30-
free(buffer);
31-
}
29+
delete[] buffer;
3230
}
3331

3432
Page(const Page& other) = delete;

0 commit comments

Comments
 (0)