* Added fDelegate member.
* Removed private AutoDeleter class. The shared ArrayDeleter is used instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22538 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e701d86af5
commit
b3e7c4a4b9
@ -173,9 +173,10 @@ private:
|
|||||||
friend class BDiskSystem;
|
friend class BDiskSystem;
|
||||||
friend class BMutablePartition;
|
friend class BMutablePartition;
|
||||||
|
|
||||||
BDiskDevice *fDevice;
|
BDiskDevice* fDevice;
|
||||||
BPartition *fParent;
|
BPartition* fParent;
|
||||||
user_partition_data *fPartitionData;
|
user_partition_data* fPartitionData;
|
||||||
|
Delegate* fDelegate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PARTITION_H
|
#endif // _PARTITION_H
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
* Ingo Weinhold, bonefish@cs.tu-berlin.de
|
* Ingo Weinhold, bonefish@cs.tu-berlin.de
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <syscalls.h>
|
#include <new>
|
||||||
#include <disk_device_manager/ddm_userland_interface.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <DiskDevice.h>
|
#include <DiskDevice.h>
|
||||||
@ -23,10 +24,10 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <AutoDeleter.h>
|
||||||
#include <new>
|
|
||||||
#include <unistd.h>
|
#include <disk_device_manager/ddm_userland_interface.h>
|
||||||
#include <sys/stat.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
using std::nothrow;
|
using std::nothrow;
|
||||||
@ -41,32 +42,6 @@ using std::nothrow;
|
|||||||
(\see IsEmpty()).
|
(\see IsEmpty()).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// AutoDeleter
|
|
||||||
/*! \brief Helper class deleting objects automatically.
|
|
||||||
*/
|
|
||||||
template<typename C>
|
|
||||||
class AutoDeleter {
|
|
||||||
public:
|
|
||||||
inline AutoDeleter(C *data = NULL, bool array = false)
|
|
||||||
: fData(data), fArray(array) {}
|
|
||||||
|
|
||||||
inline ~AutoDeleter()
|
|
||||||
{
|
|
||||||
if (fArray)
|
|
||||||
delete[] fData;
|
|
||||||
else
|
|
||||||
delete fData;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SetTo(C *data, bool array = false)
|
|
||||||
{
|
|
||||||
fData = data;
|
|
||||||
fArray = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
C *fData;
|
|
||||||
bool fArray;
|
|
||||||
};
|
|
||||||
|
|
||||||
// compare_string
|
// compare_string
|
||||||
/*! \brief \c NULL aware strcmp().
|
/*! \brief \c NULL aware strcmp().
|
||||||
@ -97,7 +72,8 @@ compare_string(const char *str1, const char *str2)
|
|||||||
BPartition::BPartition()
|
BPartition::BPartition()
|
||||||
: fDevice(NULL),
|
: fDevice(NULL),
|
||||||
fParent(NULL),
|
fParent(NULL),
|
||||||
fPartitionData(NULL)
|
fPartitionData(NULL),
|
||||||
|
fDelegate(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,14 +715,14 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
|||||||
int32 descendantCount = _CountDescendants();
|
int32 descendantCount = _CountDescendants();
|
||||||
partition_id *unmovableIDs = NULL;
|
partition_id *unmovableIDs = NULL;
|
||||||
partition_id *needUnmountingIDs = NULL;
|
partition_id *needUnmountingIDs = NULL;
|
||||||
AutoDeleter<partition_id> deleter1;
|
ArrayDeleter<partition_id> deleter1;
|
||||||
AutoDeleter<partition_id> deleter2;
|
ArrayDeleter<partition_id> deleter2;
|
||||||
if (descendantCount > 0) {
|
if (descendantCount > 0) {
|
||||||
// allocate arrays
|
// allocate arrays
|
||||||
unmovableIDs = new(nothrow) partition_id[descendantCount];
|
unmovableIDs = new(nothrow) partition_id[descendantCount];
|
||||||
needUnmountingIDs = new(nothrow) partition_id[descendantCount];
|
needUnmountingIDs = new(nothrow) partition_id[descendantCount];
|
||||||
deleter1.SetTo(unmovableIDs, true);
|
deleter1.SetTo(unmovableIDs);
|
||||||
deleter2.SetTo(needUnmountingIDs, true);
|
deleter2.SetTo(needUnmountingIDs);
|
||||||
if (!unmovableIDs || !needUnmountingIDs)
|
if (!unmovableIDs || !needUnmountingIDs)
|
||||||
return false;
|
return false;
|
||||||
// init arrays
|
// init arrays
|
||||||
|
Loading…
Reference in New Issue
Block a user