diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index 5377f30ae1..f664a011f4 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -7,6 +7,8 @@ //! Transaction and logging +#include + #include "Journal.h" #include "Debug.h" @@ -799,8 +801,8 @@ Journal::_WriteTransactionToLog() int32 maxVecs = runArrays.MaxArrayLength() + 1; // one extra for the index block - iovec* vecs = (iovec*)malloc(sizeof(iovec) * maxVecs); - if (vecs == NULL) { + BStackOrHeapArray vecs(maxVecs); + if (!vecs.IsValid()) { // TODO: write back log entries directly? return B_NO_MEMORY; } @@ -836,10 +838,8 @@ Journal::_WriteTransactionToLog() // make blocks available in the cache const void* data = block_cache_get(fVolume->BlockCache(), blockNumber + j); - if (data == NULL) { - free(vecs); + if (data == NULL) return B_IO_ERROR; - } add_to_iovec(vecs, index, maxVecs, data, fVolume->BlockSize()); count++; @@ -867,8 +867,6 @@ Journal::_WriteTransactionToLog() logStart = logPosition % fLogSize; } - free(vecs); - LogEntry* logEntry = new(std::nothrow) LogEntry(this, fVolume->LogEnd(), runArrays.LogEntryLength()); if (logEntry == NULL) {