Improve SHOW_MEMORY accounting
This commit is contained in:
@@ -41,8 +41,10 @@ public:
|
||||
// not sealed.
|
||||
void addref() const { ++referenceCount; }
|
||||
void delref() const {
|
||||
if (delref_no_destroy())
|
||||
delete (Subclass *)this;
|
||||
if (delref_no_destroy()) {
|
||||
((Subclass *)this)->~Subclass();
|
||||
safe_free((void *)this, sizeof(Subclass));
|
||||
}
|
||||
}
|
||||
bool delref_no_destroy() const { return !--referenceCount; }
|
||||
int32_t debugGetReferenceCount() const {
|
||||
@@ -146,7 +148,8 @@ private:
|
||||
};
|
||||
|
||||
template <class P, class... Args> Reference<P> makeReference(Args &&...args) {
|
||||
return Reference<P>(new P(std::forward<Args>(args)...));
|
||||
return Reference<P>(new (safe_malloc(sizeof(P)))
|
||||
P(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <class P>
|
||||
|
Reference in New Issue
Block a user