File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,13 @@ class Page {
31
31
32
32
public:
33
33
/* * Constructor. Zeros out the page data. */
34
- Page () { ResetMemory (); }
34
+ Page () {
35
+ data_ = new char [BUSTUB_PAGE_SIZE];
36
+ ResetMemory ();
37
+ }
35
38
36
39
/* * Default destructor. */
37
- ~Page () = default ;
40
+ ~Page () { delete[] data_; }
38
41
39
42
/* * @return the actual data contained within this page */
40
43
inline auto GetData () -> char * { return data_; }
@@ -79,7 +82,9 @@ class Page {
79
82
inline void ResetMemory () { memset (data_, OFFSET_PAGE_START, BUSTUB_PAGE_SIZE); }
80
83
81
84
/* * 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_;
83
88
/* * The ID of this page. */
84
89
page_id_t page_id_ = INVALID_PAGE_ID;
85
90
/* * The pin count of this page. */
You can’t perform that action at this time.
0 commit comments