Skip to content

Commit c36034a

Browse files
committed
release v2.2.0
1 parent cc89b1b commit c36034a

16 files changed

+49
-32
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Develop
44

5+
## v2.2.0
6+
57
- Rework library CMake with removed INTERFACE type
68
- Add `LWMEM_CFG_FULL` to allow control build configuration of the library
79
- Implement support for simple (no realloc, no free, grow-only malloc) allocation mechanism

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Supports embedded applications with fragmented memories
1414
* Supports automotive applications
1515
* Supports advanced free/realloc algorithms to optimize memory usage
16+
* **Since v2.2.0** Supports light implementation with allocation only
1617
* Operating system ready, thread-safe API
1718
* C++ wrapper functions
1819
* User friendly MIT license

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Features
2525
* Supports embedded applications with fragmented memories
2626
* Supports automotive applications
2727
* Supports advanced free/realloc algorithms to optimize memory usage
28+
* **Since v2.2.0** Supports light implementation with allocation only
2829
* Operating system ready, thread-safe API
2930
* C++ wrapper functions
3031
* User friendly MIT license

docs/user-manual/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ User manual
99
how-it-works
1010
instances
1111
realloc-algorithm
12+
light-version
1213
thread-safety

docs/user-manual/light-version.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _light_version:
2+
3+
LwMEM light implementation
4+
==========================
5+
6+
When system is super memory constrained or when system only requires memory allocation at initialization stage,
7+
it is possible to put the library into *light* mode by controlling the :c:macro:`LWMEM_CFG_FULL` user configuration option
8+
9+
When *full* mode is disabled, user must be aware of some contraints:
10+
11+
* It is only possible to allocate memory (no free, no realloc)
12+
* It is only possible to use one (``1``) memory region. When assigning the memory with more than one region, function will return an error.
13+
14+
.. tip::
15+
Light mode is useful for opaque types that are returned to user and must be allocated on the heap.
16+
These are typically allocated at initialization stage and never freed during program execution.
17+
18+
.. toctree::
19+
:maxdepth: 2

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "LwMEM",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Lightweight dynamic memory manager optimized for embedded systems",
55
"keywords": "lwmem, memory, dynamic, heap, malloc, calloc, realloc, free, lightweight, manager, embedded, stm32, win32",
66
"repository": {

lwmem/src/include/lwmem/lwmem.h

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#ifndef LWMEM_HDR_H
3535
#define LWMEM_HDR_H
@@ -125,6 +125,7 @@ size_t lwmem_get_size_ex(lwmem_t* lwobj, void* ptr);
125125
#endif /* LWMEM_CFG_FULL || __DOXYGEN__ */
126126
#if LWMEM_CFG_ENABLE_STATS || __DOXYGEN__
127127
void lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats);
128+
void lwmem_get_size(lwmem_stats_t* stats);
128129
#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */
129130

130131
size_t lwmem_assignmem(const lwmem_region_t* regions);
@@ -137,20 +138,8 @@ int lwmem_realloc_s(void** ptr2ptr, size_t size);
137138
void lwmem_free(void* ptr);
138139
void lwmem_free_s(void** ptr2ptr);
139140
size_t lwmem_get_size(void* ptr);
140-
141141
#endif /* LWMEM_CFG_FULL || __DOXYGEN__ */
142142

143-
#if LWMEM_CFG_ENABLE_STATS || __DOXYGEN__
144-
145-
/**
146-
* \note This is a wrapper for \ref lwmem_get_stats_ex function.
147-
* It operates in default LwMEM instance
148-
* \param[in] ptr: Pointer to lwmem_stats_t to store result
149-
*/
150-
#define lwmem_get_stats(stats) lwmem_get_stats_ex(NULL, (stats))
151-
152-
#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */
153-
154143
#if defined(LWMEM_DEV) && !__DOXYGEN__
155144
unsigned char lwmem_debug_create_regions(lwmem_region_t** regs_out, size_t count, size_t size);
156145
void lwmem_debug_save_state(void);

lwmem/src/include/lwmem/lwmem.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#ifndef LWMEM_HDR_HPP
3535
#define LWMEM_HDR_HPP

lwmem/src/include/lwmem/lwmem_opt.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#ifndef LWMEM_OPT_HDR_H
3535
#define LWMEM_OPT_HDR_H
@@ -89,7 +89,7 @@ extern "C" {
8989
* \brief Enables `1` or disables `0` full memory management support.
9090
*
9191
* When enabled (default config), library supports allocation, reallocation and freeing of the memory.
92-
* - Memory allocation and [c]allocation
92+
* - Memory [c]allocation
9393
* - Memory reallocation
9494
* - Memory allocation in user defined memory regions
9595
* - Memory freeing

lwmem/src/include/lwmem/lwmem_opts_template.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#ifndef LWMEM_OPTS_HDR_H
3535
#define LWMEM_OPTS_HDR_H

lwmem/src/include/system/lwmem_sys.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#ifndef LWMEM_SYS_HDR_H
3535
#define LWMEM_SYS_HDR_H

lwmem/src/lwmem/lwmem.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#include "lwmem/lwmem.h"
3535
#include <limits.h>
@@ -1146,7 +1146,7 @@ lwmem_get_size_ex(lwmem_t* lwobj, void* ptr) {
11461146
* \brief Get statistics of a LwMEM instance
11471147
* \param[in] lwobj: LwMEM instance. Set to `NULL` to use default instance.
11481148
* Instance must be the same as used during allocation procedure
1149-
* \param[in] stats: Pointer to \ref lwmem_stats_t to store result
1149+
* \param[in,out] stats: Pointer to \ref lwmem_stats_t to store result
11501150
*/
11511151
void
11521152
lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats) {
@@ -1159,6 +1159,15 @@ lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats) {
11591159
}
11601160
}
11611161

1162+
/**
1163+
* \brief Get statistics of a default LwMEM instance
1164+
* \param[in,out] stats: Pointer to \ref lwmem_stats_t to store result
1165+
*/
1166+
size_t
1167+
lwmem_get_size(lwmem_stats_t* stats) {
1168+
lwmem_get_stats_ex(NULL, stats);
1169+
}
1170+
11621171
#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */
11631172

11641173
/**

lwmem/src/lwmem/lwmem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/

lwmem/src/system/lwmem_sys_cmsis_os.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#include "system/lwmem_sys.h"
3535

lwmem/src/system/lwmem_sys_threadx.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#include "system/lwmem_sys.h"
3535

lwmem/src/system/lwmem_sys_win32.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
* This file is part of LwMEM - Lightweight dynamic memory manager library.
3030
*
3131
* Author: Tilen MAJERLE <[email protected]>
32-
* Version: v2.1.0
32+
* Version: v2.2.0
3333
*/
3434
#include "system/lwmem_sys.h"
3535

3636
#if LWMEM_CFG_OS && !__DOXYGEN__
3737

38-
#include "Windows.h"
38+
#include "windows.h"
3939

4040
uint8_t
4141
lwmem_sys_mutex_create(LWMEM_CFG_OS_MUTEX_HANDLE* m) {
@@ -50,12 +50,7 @@ lwmem_sys_mutex_isvalid(LWMEM_CFG_OS_MUTEX_HANDLE* m) {
5050

5151
uint8_t
5252
lwmem_sys_mutex_wait(LWMEM_CFG_OS_MUTEX_HANDLE* m) {
53-
DWORD ret;
54-
ret = WaitForSingleObject(*m, INFINITE);
55-
if (ret != WAIT_OBJECT_0) {
56-
return 0;
57-
}
58-
return 1;
53+
return WaitForSingleObject(*m, INFINITE) == WAIT_OBJECT_0;
5954
}
6055

6156
uint8_t

0 commit comments

Comments
 (0)