AutoDeleter: fix AutoDeleter size

C++ don't allow zero size class fields. If field with empty class field
is used, it's size will be 1 byte.

Create DeleteFunc instance as local variable at each use instead.

Fixes #16638.

Change-Id: Ifb76c45ea02e9fed014751542ee5f16f41e11d15
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3458
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
X512 2020-12-04 23:17:04 +09:00 committed by Adrien Destugues
parent ab57ee42cb
commit 76ab85671d

View File

@ -39,13 +39,15 @@ public:
inline ~AutoDeleter()
{
fDelete(fObject);
DeleteFunc destructor;
destructor(fObject);
}
inline void SetTo(C *object)
{
if (object != fObject) {
fDelete(fObject);
DeleteFunc destructor;
destructor(fObject);
fObject = object;
}
}
@ -79,7 +81,6 @@ public:
protected:
C *fObject;
DeleteFunc fDelete;
private:
AutoDeleter(const AutoDeleter&);