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:
parent
ab57ee42cb
commit
76ab85671d
@ -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&);
|
||||
|
Loading…
Reference in New Issue
Block a user