Skip to content

Commit 2eb0bca

Browse files
committed
Moved MemBlockDevice allocation of block pointers to new
per @sg- on mbed-os#3449
1 parent c5e758f commit 2eb0bca

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

features/filesystem/bd/MemBlockDevice.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,18 @@ MemBlockDevice::~MemBlockDevice()
3131
free(_blocks[i]);
3232
}
3333

34-
free(_blocks);
34+
delete[] _blocks;
3535
_blocks = 0;
3636
}
3737
}
3838

3939
bd_error_t MemBlockDevice::init()
4040
{
4141
if (!_blocks) {
42-
_blocks = (uint8_t**)malloc(_count*sizeof(uint8_t*));
43-
if (!_blocks) {
44-
return BD_ERROR_DEVICE_ERROR;
42+
_blocks = new uint8_t*[_count];
43+
for (unsigned i = 0; i < _count; i++) {
44+
_blocks[i] = 0;
4545
}
46-
47-
memset(_blocks, 0, _count*sizeof(uint8_t*));
4846
}
4947

5048
return BD_ERROR_OK;

0 commit comments

Comments
 (0)