Skip to content

Commit 278199d

Browse files
committed
Renamed MemBlockDevice -> HeapBlockDevice
options: MemBlockDevice - Same as mbed 2 class, but ambiguous RAMBlockDevice - May be ambiguous with BD on unmanaged RAM HeapBlockDevice - Seems the most reasonable name
1 parent 2eb0bca commit 278199d

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

features/TESTS/filesystem/fat_file_system/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#include "unity.h"
44
#include "utest.h"
55

6-
#include "MemBlockDevice.h"
6+
#include "HeapBlockDevice.h"
77
#include "FATFileSystem.h"
88
#include <stdlib.h>
99

1010
using namespace utest::v1;
1111

1212
// Test block device
1313
#define BLOCK_SIZE 512
14-
MemBlockDevice bd(128, BLOCK_SIZE);
14+
HeapBlockDevice bd(128, BLOCK_SIZE);
1515

1616

1717
void test_format() {

features/TESTS/filesystem/mem_block_device/main.cpp renamed to features/TESTS/filesystem/heap_block_device/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "unity.h"
44
#include "utest.h"
55

6-
#include "MemBlockDevice.h"
6+
#include "HeapBlockDevice.h"
77
#include <stdlib.h>
88

99
using namespace utest::v1;
@@ -14,7 +14,7 @@ uint8_t read_block[BLOCK_SIZE];
1414

1515

1616
void test_read_write() {
17-
MemBlockDevice bd(16, BLOCK_SIZE);
17+
HeapBlockDevice bd(16, BLOCK_SIZE);
1818

1919
int err = bd.init();
2020
TEST_ASSERT_EQUAL(0, err);

features/filesystem/bd/MemBlockDevice.cpp renamed to features/filesystem/bd/HeapBlockDevice.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "MemBlockDevice.h"
17+
#include "HeapBlockDevice.h"
1818

1919

20-
MemBlockDevice::MemBlockDevice(bd_count_t count, bd_size_t size)
20+
HeapBlockDevice::HeapBlockDevice(bd_count_t count, bd_size_t size)
2121
: _count(count)
2222
, _size(size)
2323
, _blocks(0)
2424
{
2525
}
2626

27-
MemBlockDevice::~MemBlockDevice()
27+
HeapBlockDevice::~HeapBlockDevice()
2828
{
2929
if (_blocks) {
3030
for (bd_count_t i = 0; i < _count; i++) {
@@ -36,7 +36,7 @@ MemBlockDevice::~MemBlockDevice()
3636
}
3737
}
3838

39-
bd_error_t MemBlockDevice::init()
39+
bd_error_t HeapBlockDevice::init()
4040
{
4141
if (!_blocks) {
4242
_blocks = new uint8_t*[_count];
@@ -48,29 +48,29 @@ bd_error_t MemBlockDevice::init()
4848
return BD_ERROR_OK;
4949
}
5050

51-
bd_error_t MemBlockDevice::deinit()
51+
bd_error_t HeapBlockDevice::deinit()
5252
{
5353
// Memory is lazily cleaned up in destructor to allow
5454
// data to live across de/reinitialization
5555
return BD_ERROR_OK;
5656
}
5757

58-
bd_error_t MemBlockDevice::status()
58+
bd_error_t HeapBlockDevice::status()
5959
{
6060
return _blocks ? BD_ERROR_OK : BD_ERROR_NO_INIT;
6161
}
6262

63-
bd_size_t MemBlockDevice::get_block_size()
63+
bd_size_t HeapBlockDevice::get_block_size()
6464
{
6565
return _size;
6666
}
6767

68-
bd_block_t MemBlockDevice::get_block_count()
68+
bd_block_t HeapBlockDevice::get_block_count()
6969
{
7070
return _count;
7171
}
7272

73-
bd_count_or_error_t MemBlockDevice::read(void *b, bd_block_t block, bd_count_t count)
73+
bd_count_or_error_t HeapBlockDevice::read(void *b, bd_block_t block, bd_count_t count)
7474
{
7575
uint8_t *buffer = (uint8_t*)b;
7676
if (!_blocks || block + count > _count) {
@@ -88,7 +88,7 @@ bd_count_or_error_t MemBlockDevice::read(void *b, bd_block_t block, bd_count_t c
8888
return count;
8989
}
9090

91-
bd_count_or_error_t MemBlockDevice::write(const void *b, bd_block_t block, bd_count_t count)
91+
bd_count_or_error_t HeapBlockDevice::write(const void *b, bd_block_t block, bd_count_t count)
9292
{
9393
const uint8_t *buffer = (const uint8_t*)b;
9494
if (!_blocks || block + count > _count) {

features/filesystem/bd/MemBlockDevice.h renamed to features/filesystem/bd/HeapBlockDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22-
#ifndef MBED_MEM_BLOCK_DEVICE_H
23-
#define MBED_MEM_BLOCK_DEVICE_H
22+
#ifndef MBED_HEAP_BLOCK_DEVICE_H
23+
#define MBED_HEAP_BLOCK_DEVICE_H
2424

2525
#include "BlockDevice.h"
2626
#include "mbed.h"
@@ -32,9 +32,9 @@
3232
*
3333
* @code
3434
* #include "mbed.h"
35-
* #include "MemBlockDevice.h"
35+
* #include "HeapBlockDevice.h"
3636
*
37-
* MemBlockDevice bd(4, 512); // 4 blocks of 512 bytes
37+
* HeapBlockDevice bd(4, 512); // 4 blocks of 512 bytes
3838
* uint8_t block[512] = "Hello World!\n";
3939
*
4040
* int main() {
@@ -45,12 +45,12 @@
4545
* bd.deinit();
4646
* }
4747
*/
48-
class MemBlockDevice : public BlockDevice {
48+
class HeapBlockDevice : public BlockDevice {
4949
public:
5050
/** Lifetime of the memory block device
5151
*/
52-
MemBlockDevice(bd_count_t count = 4, bd_size_t size = 512);
53-
virtual ~MemBlockDevice();
52+
HeapBlockDevice(bd_count_t count = 4, bd_size_t size = 512);
53+
virtual ~HeapBlockDevice();
5454

5555
/** Initialize a block device
5656
*

0 commit comments

Comments
 (0)