release v2.2.0

This commit is contained in:
Tilen M 2024-10-12 15:13:19 +02:00
parent cc89b1b755
commit c36034a686
16 changed files with 49 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,4 +9,5 @@ User manual
how-it-works
instances
realloc-algorithm
light-version
thread-safety

View File

@ -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

View File

@ -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": {

View File

@ -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
@ -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);
@ -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);

View File

@ -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

View File

@ -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
@ -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

View File

@ -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

View File

@ -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

View File

@ -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>
@ -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) {
@ -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__ */
/**

View File

@ -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
*/

View File

@ -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"

View File

@ -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"

View File

@ -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) {
@ -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