Skip to content

Commit

Permalink
release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Oct 12, 2024
1 parent cc89b1b commit c36034a
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Develop

## v2.2.0

- Rework library CMake with removed INTERFACE type
- Add `LWMEM_CFG_FULL` to allow control build configuration of the library
- Implement support for simple (no realloc, no free, grow-only malloc) allocation mechanism
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Supports embedded applications with fragmented memories
* Supports automotive applications
* Supports advanced free/realloc algorithms to optimize memory usage
* **Since v2.2.0** Supports light implementation with allocation only
* Operating system ready, thread-safe API
* C++ wrapper functions
* User friendly MIT license
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Features
* Supports embedded applications with fragmented memories
* Supports automotive applications
* Supports advanced free/realloc algorithms to optimize memory usage
* **Since v2.2.0** Supports light implementation with allocation only
* Operating system ready, thread-safe API
* C++ wrapper functions
* User friendly MIT license
Expand Down
1 change: 1 addition & 0 deletions docs/user-manual/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ User manual
how-it-works
instances
realloc-algorithm
light-version
thread-safety
19 changes: 19 additions & 0 deletions docs/user-manual/light-version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _light_version:

LwMEM light implementation
==========================

When system is super memory constrained or when system only requires memory allocation at initialization stage,
it is possible to put the library into *light* mode by controlling the :c:macro:`LWMEM_CFG_FULL` user configuration option

When *full* mode is disabled, user must be aware of some contraints:

* It is only possible to allocate memory (no free, no realloc)
* It is only possible to use one (``1``) memory region. When assigning the memory with more than one region, function will return an error.

.. tip::
Light mode is useful for opaque types that are returned to user and must be allocated on the heap.
These are typically allocated at initialization stage and never freed during program execution.

.. toctree::
:maxdepth: 2
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LwMEM",
"version": "2.1.0",
"version": "2.2.0",
"description": "Lightweight dynamic memory manager optimized for embedded systems",
"keywords": "lwmem, memory, dynamic, heap, malloc, calloc, realloc, free, lightweight, manager, embedded, stm32, win32",
"repository": {
Expand Down
15 changes: 2 additions & 13 deletions lwmem/src/include/lwmem/lwmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#ifndef LWMEM_HDR_H
#define LWMEM_HDR_H
Expand Down Expand Up @@ -125,6 +125,7 @@ size_t lwmem_get_size_ex(lwmem_t* lwobj, void* ptr);
#endif /* LWMEM_CFG_FULL || __DOXYGEN__ */
#if LWMEM_CFG_ENABLE_STATS || __DOXYGEN__
void lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats);
void lwmem_get_size(lwmem_stats_t* stats);
#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */

size_t lwmem_assignmem(const lwmem_region_t* regions);
Expand All @@ -137,20 +138,8 @@ int lwmem_realloc_s(void** ptr2ptr, size_t size);
void lwmem_free(void* ptr);
void lwmem_free_s(void** ptr2ptr);
size_t lwmem_get_size(void* ptr);

#endif /* LWMEM_CFG_FULL || __DOXYGEN__ */

#if LWMEM_CFG_ENABLE_STATS || __DOXYGEN__

/**
* \note This is a wrapper for \ref lwmem_get_stats_ex function.
* It operates in default LwMEM instance
* \param[in] ptr: Pointer to lwmem_stats_t to store result
*/
#define lwmem_get_stats(stats) lwmem_get_stats_ex(NULL, (stats))

#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */

#if defined(LWMEM_DEV) && !__DOXYGEN__
unsigned char lwmem_debug_create_regions(lwmem_region_t** regs_out, size_t count, size_t size);
void lwmem_debug_save_state(void);
Expand Down
2 changes: 1 addition & 1 deletion lwmem/src/include/lwmem/lwmem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#ifndef LWMEM_HDR_HPP
#define LWMEM_HDR_HPP
Expand Down
4 changes: 2 additions & 2 deletions lwmem/src/include/lwmem/lwmem_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#ifndef LWMEM_OPT_HDR_H
#define LWMEM_OPT_HDR_H
Expand Down Expand Up @@ -89,7 +89,7 @@ extern "C" {
* \brief Enables `1` or disables `0` full memory management support.
*
* When enabled (default config), library supports allocation, reallocation and freeing of the memory.
* - Memory allocation and [c]allocation
* - Memory [c]allocation
* - Memory reallocation
* - Memory allocation in user defined memory regions
* - Memory freeing
Expand Down
2 changes: 1 addition & 1 deletion lwmem/src/include/lwmem/lwmem_opts_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#ifndef LWMEM_OPTS_HDR_H
#define LWMEM_OPTS_HDR_H
Expand Down
2 changes: 1 addition & 1 deletion lwmem/src/include/system/lwmem_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#ifndef LWMEM_SYS_HDR_H
#define LWMEM_SYS_HDR_H
Expand Down
13 changes: 11 additions & 2 deletions lwmem/src/lwmem/lwmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#include "lwmem/lwmem.h"
#include <limits.h>
Expand Down Expand Up @@ -1146,7 +1146,7 @@ lwmem_get_size_ex(lwmem_t* lwobj, void* ptr) {
* \brief Get statistics of a LwMEM instance
* \param[in] lwobj: LwMEM instance. Set to `NULL` to use default instance.
* Instance must be the same as used during allocation procedure
* \param[in] stats: Pointer to \ref lwmem_stats_t to store result
* \param[in,out] stats: Pointer to \ref lwmem_stats_t to store result
*/
void
lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats) {
Expand All @@ -1159,6 +1159,15 @@ lwmem_get_stats_ex(lwmem_t* lwobj, lwmem_stats_t* stats) {
}
}

/**
* \brief Get statistics of a default LwMEM instance
* \param[in,out] stats: Pointer to \ref lwmem_stats_t to store result
*/
size_t
lwmem_get_size(lwmem_stats_t* stats) {
lwmem_get_stats_ex(NULL, stats);
}

#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */

/**
Expand Down
2 changes: 1 addition & 1 deletion lwmem/src/lwmem/lwmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
2 changes: 1 addition & 1 deletion lwmem/src/system/lwmem_sys_cmsis_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#include "system/lwmem_sys.h"

Expand Down
2 changes: 1 addition & 1 deletion lwmem/src/system/lwmem_sys_threadx.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#include "system/lwmem_sys.h"

Expand Down
11 changes: 3 additions & 8 deletions lwmem/src/system/lwmem_sys_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.1.0
* Version: v2.2.0
*/
#include "system/lwmem_sys.h"

#if LWMEM_CFG_OS && !__DOXYGEN__

#include "Windows.h"
#include "windows.h"

uint8_t
lwmem_sys_mutex_create(LWMEM_CFG_OS_MUTEX_HANDLE* m) {
Expand All @@ -50,12 +50,7 @@ lwmem_sys_mutex_isvalid(LWMEM_CFG_OS_MUTEX_HANDLE* m) {

uint8_t
lwmem_sys_mutex_wait(LWMEM_CFG_OS_MUTEX_HANDLE* m) {
DWORD ret;
ret = WaitForSingleObject(*m, INFINITE);
if (ret != WAIT_OBJECT_0) {
return 0;
}
return 1;
return WaitForSingleObject(*m, INFINITE) == WAIT_OBJECT_0;
}

uint8_t
Expand Down

0 comments on commit c36034a

Please sign in to comment.