Fixed a potential memory leak. If any operation prior to the addition of the job queue to the manager failed, it wouldn't be deleted. Now the job generator deletes it by default and must be told via DetachJobQueue() to not do that.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4222 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,6 +45,7 @@ KDiskDeviceJobGenerator::~KDiskDeviceJobGenerator()
|
||||
{
|
||||
delete[] fMoveInfos;
|
||||
delete[] fPartitionIDs;
|
||||
delete fJobQueue;
|
||||
}
|
||||
|
||||
// JobFactory
|
||||
@@ -68,6 +69,15 @@ KDiskDeviceJobGenerator::JobQueue() const
|
||||
return fJobQueue;
|
||||
}
|
||||
|
||||
// DetachJobQueue
|
||||
KDiskDeviceJobQueue *
|
||||
KDiskDeviceJobGenerator::DetachJobQueue()
|
||||
{
|
||||
KDiskDeviceJobQueue *jobQueue = fJobQueue;
|
||||
fJobQueue = NULL;
|
||||
return jobQueue;
|
||||
}
|
||||
|
||||
// GenerateJobs
|
||||
status_t
|
||||
KDiskDeviceJobGenerator::GenerateJobs()
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
KDiskDevice *Device() const;
|
||||
KDiskDeviceJobQueue *JobQueue() const;
|
||||
|
||||
KDiskDeviceJobQueue *DetachJobQueue();
|
||||
|
||||
status_t GenerateJobs();
|
||||
|
||||
private:
|
||||
|
||||
@@ -1230,7 +1230,9 @@ _kern_commit_disk_device_modifications(partition_id deviceID, port_id port,
|
||||
// add the jobs to the manager
|
||||
if (ManagerLocker locker2 = manager) {
|
||||
error = manager->AddJobQueue(generator.JobQueue());
|
||||
if (error != B_OK)
|
||||
if (error == B_OK)
|
||||
generator.DetachJobQueue();
|
||||
else
|
||||
return error;
|
||||
} else
|
||||
return B_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user