hatcat / cg30_issues

The public issues repository for the book "Beautiful C++"
4 stars 1 forks source link

Page 299/300: Memory leak with `DATABASE_PROXY` #40

Open Ukilele opened 2 years ago

Ukilele commented 2 years ago

In the code sample on page 299 and 300 there is a memory leak. While std::default_delete<DATABASE_PROXY>::operator() calls close_database(*p), it does not call delete p. I.e. it does not destroy the object of type DATABASE_PROXY that gets constructed on page 300 when calling new DATABASE_PROXY(....

Label: 5.6: E6