Skip to content

Commit dad52dc

Browse files
tobhemoenoel
authored andcommitted
memarray: fixed formatting and typos
1 parent d1210e3 commit dad52dc

5 files changed

Lines changed: 10 additions & 14 deletions

File tree

sys/include/memarray.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef struct {
3434

3535
/**
3636
* @brief Define static memory pool
37+
*
3738
* @param[out] name name for defined memarray pool
3839
* @param[in] size size of single memory chunk
3940
* @param[in] num number of chunks in pool
@@ -44,6 +45,7 @@ typedef struct {
4445

4546
/**
4647
* @brief Initialize memarray pool with free list
48+
*
4749
* @param[out] mem memarray pool to initialize
4850
* @param[in] size size of single memory chunk
4951
* @param[in] num number of chunks in pool
@@ -52,14 +54,16 @@ void memarray_init(memarray_t *mem, size_t num, size_t size);
5254

5355
/**
5456
* @brief Allocate memory chunk in memarray pool
57+
*
5558
* @param[in,out] mem memarray pool to allocate block in
56-
* @return pointer to newly allocated memarray chunk
59+
*
5760
* @return NULL on failure
5861
*/
5962
void *memarray_alloc(memarray_t *mem);
6063

6164
/**
6265
* @brief Free memory chunk in memarray pool
66+
*
6367
* @param[in,out] mem memarray pool to free block in
6468
* @param[in] ptr pointer to memarray chunk
6569
*/

sys/memarray/memarray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void *memarray_alloc(memarray_t *mem)
2121

2222
void memarray_init(memarray_t *mem, size_t size, size_t num)
2323
{
24-
for (size_t i = 0; i < num - 1; i++) {
24+
for (size_t i = 0; i < (num - 1); i++) {
2525
void *next = ((char *)mem->first_free) + ((i + 1) * size);
2626
memcpy(((char *)mem->first_free) + (i * size), &next, sizeof(void *));
2727
}

tests/memarray/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,4 @@ USEMODULE += memarray
88
USEMODULE += shell_commands
99
USEMODULE += ps
1010

11-
# Comment this out to disable code in RIOT that does safety checking
12-
# which is not needed in a production environment but helps in the
13-
# development process:
14-
CFLAGS += -DDEVELHELP
15-
1611
include $(RIOTBASE)/Makefile.include

tests/memarray/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This test is passed if the memory used by the main thread remains static.
1111
Background
1212
==========
1313

14-
The module `memarray` is the static memory allocator for RIOT O.S.
14+
The module `memarray` is the static memory allocator for RIOT-OS
1515

1616
This test application is therefore specialized for only testing the use of the module.
1717

tests/memarray/main.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
#include "memarray.h"
2727

28-
#define MAX_NUMBER_BLOCKS 10
29-
#define MESSAGE_SIZE 8
30-
#define NUMBER_OF_TESTS 12
28+
#define MAX_NUMBER_BLOCKS (10U)
29+
#define MESSAGE_SIZE (8U)
30+
#define NUMBER_OF_TESTS (12U)
3131

3232
extern int _ps_handler(int argc, char **argv);
3333

@@ -40,7 +40,6 @@ struct block_t {
4040

4141
MEMARRAY(block_storage, sizeof(struct block_t), MAX_NUMBER_BLOCKS)
4242

43-
4443
int total = 0;
4544

4645
static void memory_block_init(void)
@@ -76,7 +75,6 @@ void free_memory(struct block_t *head)
7675
struct block_t *old;
7776

7877
while (head) {
79-
8078
total -= sizeof(struct block_t);
8179
printf("\tFree (%i) %d Bytes at 0x%p, total %d\n", \
8280
head->number, sizeof(struct block_t), (void *)head, total);
@@ -96,7 +94,6 @@ void free_memory(struct block_t *head)
9694

9795
int main(void)
9896
{
99-
10097
memory_block_init();
10198
int count = 0;
10299

0 commit comments

Comments
 (0)