GH-49408: [C++][Parquet] Add protected non-virtual destructor to parquet::Page#49409
GH-49408: [C++][Parquet] Add protected non-virtual destructor to parquet::Page#49409HuaHuaY wants to merge 1 commit intoapache:mainfrom
parquet::Page#49409Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds a protected non-virtual destructor to the parquet::Page base class to clarify design intent and improve type safety. The change prevents deletion of Page subclasses through raw Page* pointers, which would previously result in memory leaks or undefined behavior. The existing codebase uses std::shared_ptr for all Page object management, which remains safe with this change because the shared pointer stores the correct deleter for the actual derived class.
Changes:
- Added protected non-virtual destructor to
parquet::Pageclass
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rationale for this change
Clarify the destructor implementation of
parquet::Pageto expose the design intent.What changes are included in this PR?
Add protected non-virtual destructor to
parquet::Page.Are these changes tested?
Yes.
Are there any user-facing changes?
Yes. If someone used
Page*orstd::unique_ptr<Page>to release a subclass object before, it would get a memory leak. And now it gets a compile error.parquet::Page#49408