Skip to content

Commit 49deaa1

Browse files
authored
chore: use ptr for page (#506)
Signed-off-by: Alex Chi <[email protected]>
1 parent e257384 commit 49deaa1

File tree

1 file changed

+8
-3
lines changed
  • src/include/storage/page

1 file changed

+8
-3
lines changed

src/include/storage/page/page.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ class Page {
3131

3232
public:
3333
/** Constructor. Zeros out the page data. */
34-
Page() { ResetMemory(); }
34+
Page() {
35+
data_ = new char[BUSTUB_PAGE_SIZE];
36+
ResetMemory();
37+
}
3538

3639
/** Default destructor. */
37-
~Page() = default;
40+
~Page() { delete[] data_; }
3841

3942
/** @return the actual data contained within this page */
4043
inline auto GetData() -> char * { return data_; }
@@ -79,7 +82,9 @@ class Page {
7982
inline void ResetMemory() { memset(data_, OFFSET_PAGE_START, BUSTUB_PAGE_SIZE); }
8083

8184
/** The actual data that is stored within a page. */
82-
char data_[BUSTUB_PAGE_SIZE]{};
85+
// Usually this should be stored as `char data_[BUSTUB_PAGE_SIZE]{};`. But to enable ASAN to detect page overflow,
86+
// we store it as a ptr.
87+
char *data_;
8388
/** The ID of this page. */
8489
page_id_t page_id_ = INVALID_PAGE_ID;
8590
/** The pin count of this page. */

0 commit comments

Comments
 (0)