[riot-notifications] [RIOT-OS/RIOT] [WIP] Generic memory block allocator (#7651)

Sebastian Meiling notifications at github.com
Wed Sep 27 22:28:22 CEST 2017


smlng requested changes on this pull request.

some initial comments, and generally: please adapt to RIOT coding style, that is 4 spaces intend (not 2), open braces for function on new line. See wiki.

> + * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+#ifndef MEMARRAY_H
+#define MEMARRAY_H
+
+#include "stdint.h"
+#include "stdlib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup    sys_memarray memory array allocator

please move this comment block up, directly below the copy right statement - just for consistency with RIOT codebase.

> @@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Tobias Heider <heidert at nm.ifi.lmu.de>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+#ifndef MEMARRAY_H
+#define MEMARRAY_H
+
+#include "stdint.h"

these standard includes should go into `<` and `>`

> +#include "stdlib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup    sys_memarray memory array allocator
+ * @ingroup     sys
+ * @brief       memory array allocator
+ * @{
+ *
+ * @brief       pseudo dynamic allocation in static memory arrays
+ * @author      Tobias Heider <heidert at nm.ifi.lmu.de>
+ */
+typedef struct {

struct need documentation, plus its elements, i.e. 
```
    size_t size;    /**< size of memory array */
    size_t count;   /**< number of ... */
```


> +  size_t count;
+  void *first_free;
+  void *data;
+} memarray_t;
+
+/**
+ * Initialize memory
+ */
+#define MEMARRAY(name, structure, num)                                         \
+  static structure _data_##name[num];                                          \
+  static memarray_t name = {.size = sizeof(structure),                         \
+                            .count = num,                                      \
+                            .first_free = _data_##name,                        \
+                            .data = _data_##name};
+
+void memarray_init(memarray_t *mem);

add full doxygen style documentation for all functions here and below

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7651#pullrequestreview-65673469
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170927/2095f668/attachment-0001.html>


More information about the notifications mailing list