added std::nothrow for some new calls, and initialize fCheckCookie

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42593 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2011-08-07 12:05:22 +00:00
parent 0cd93754a4
commit bdce14985b
2 changed files with 12 additions and 9 deletions
@@ -517,7 +517,8 @@ BlockAllocator::BlockAllocator(Volume* volume)
: :
fVolume(volume), fVolume(volume),
fGroups(NULL), fGroups(NULL),
fCheckBitmap(NULL) fCheckBitmap(NULL),
fCheckCookie(NULL)
{ {
mutex_init(&fLock, "bfs allocator"); mutex_init(&fLock, "bfs allocator");
} }
@@ -538,7 +539,7 @@ BlockAllocator::Initialize(bool full)
fNumBlocks = (fVolume->NumBlocks() + fVolume->BlockSize() * 8 - 1) fNumBlocks = (fVolume->NumBlocks() + fVolume->BlockSize() * 8 - 1)
/ (fVolume->BlockSize() * 8); / (fVolume->BlockSize() * 8);
fGroups = new AllocationGroup[fNumGroups]; fGroups = new(std::nothrow) AllocationGroup[fNumGroups];
if (fGroups == NULL) if (fGroups == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -1215,7 +1216,7 @@ BlockAllocator::StartChecking(const check_control* control)
return B_NO_MEMORY; return B_NO_MEMORY;
} }
fCheckCookie = new check_cookie(); fCheckCookie = new(std::nothrow) check_cookie();
if (fCheckCookie == NULL) { if (fCheckCookie == NULL) {
free(fCheckBitmap); free(fCheckBitmap);
fCheckBitmap = NULL; fCheckBitmap = NULL;
@@ -1432,7 +1433,7 @@ BlockAllocator::CheckNextNode(check_control* control)
fCheckCookie->parent = inode; fCheckCookie->parent = inode;
fCheckCookie->parent_mode = inode->Mode(); fCheckCookie->parent_mode = inode->Mode();
fCheckCookie->iterator = new TreeIterator(tree); fCheckCookie->iterator = new(std::nothrow) TreeIterator(tree);
if (fCheckCookie->iterator == NULL) if (fCheckCookie->iterator == NULL)
RETURN_ERROR(B_NO_MEMORY); RETURN_ERROR(B_NO_MEMORY);
@@ -356,7 +356,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL) if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL)
return B_ERROR; return B_ERROR;
fJournal = new Journal(this); fJournal = new(std::nothrow) Journal(this);
if (fJournal == NULL) if (fJournal == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -384,15 +384,17 @@ Volume::Mount(const char* deviceName, uint32 flags)
return status; return status;
} }
fRootNode = new Inode(this, ToVnode(Root())); fRootNode = new(std::nothrow) Inode(this, ToVnode(Root()));
if (fRootNode != NULL && fRootNode->InitCheck() == B_OK) { if (fRootNode != NULL && fRootNode->InitCheck() == B_OK) {
status = publish_vnode(fVolume, ToVnode(Root()), (void*)fRootNode, status = publish_vnode(fVolume, ToVnode(Root()), (void*)fRootNode,
&gBFSVnodeOps, fRootNode->Mode(), 0); &gBFSVnodeOps, fRootNode->Mode(), 0);
if (status == B_OK) { if (status == B_OK) {
// try to get indices root dir // try to get indices root dir
if (!Indices().IsZero()) if (!Indices().IsZero()) {
fIndicesNode = new Inode(this, ToVnode(Indices())); fIndicesNode = new(std::nothrow) Inode(this,
ToVnode(Indices()));
}
if (fIndicesNode == NULL if (fIndicesNode == NULL
|| fIndicesNode->InitCheck() < B_OK || fIndicesNode->InitCheck() < B_OK
@@ -690,7 +692,7 @@ Volume::Initialize(int fd, const char* name, uint32 blockSize,
if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL) if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL)
return B_ERROR; return B_ERROR;
fJournal = new Journal(this); fJournal = new(std::nothrow) Journal(this);
if (fJournal == NULL || fJournal->InitCheck() < B_OK) if (fJournal == NULL || fJournal->InitCheck() < B_OK)
RETURN_ERROR(B_ERROR); RETURN_ERROR(B_ERROR);