Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Apr 11, 2021
2 parents 5736774 + 725454a commit 53e784a
Show file tree
Hide file tree
Showing 26 changed files with 149 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: ['paypal.me/tilz0R']
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Changelog

## Develop

## v1.5.0

- Add option to cleanup memory on free and realloc operations

## v1.4.0

- New artistic code style
- Replace configuration
- Several bug fixes

## v1.3.0

- Added option for custom LwMEM instance for complete isolation
- Added `_ex` functions for extended features for custom instances
- Added macros for backward-compatible, default instance, allocation functions
- Added option to force LwMEM to allocate memory at specific region
- Added win32 examples

## v1.2.0

- Fix comments to easily undestand architecture
- Migrate examples to CMSIS-OS v2
- Use pre-increment instead of post-increment
- Other C code style fixes

## v1.1.0

- Added support for thread-safety application
- Added boundary check of all internal pointers
- Added tests code directly in library
- Bug fixes
10 changes: 6 additions & 4 deletions dev/VisualStudio/lwmem_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand All @@ -42,7 +42,9 @@
* Open "include/lwmem/lwmem_opt.h" and
* copy & replace here settings you want to change values
*/
#define LWMEM_CFG_OS 1
#define LWMEM_CFG_OS_MUTEX_HANDLE HANDLE
#define LWMEM_CFG_OS 1
#define LWMEM_CFG_OS_MUTEX_HANDLE HANDLE
#define LWMEM_CFG_ENABLE_STATS 0
#define LWMEM_CFG_CLEAN_MEMORY 1

#endif /* OW_HDR_OPTS_H */
#endif /* LWMEM_HDR_OPTS_H */
29 changes: 17 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,32 @@
copyright = '2020, Tilen MAJERLE'
author = 'Tilen MAJERLE'

# The full version, including alpha/beta/rc tags
version = '1.4.0'

# Try to get branch at which this is running
# and try to determine which version to display in sphinx
# Version is using git tag if on master or "latest-develop" if on develop branch
version = ''
git_branch = ''

# Get current branch
res = os.popen('git branch').read().strip()
for line in res.split("\n"):
if line[0] == '*':
git_branch = line[1:].strip()

# Decision for display version
try:
if git_branch.index('develop') >= 0:
version = "latest-develop"
except Exception:
print("Exception for index check")

# For debugging purpose
git_branch = git_branch.replace('(HEAD detached at ', '').replace(')', '')
if git_branch.find('master') >= 0 or git_branch.find('main') >= 0:
version = os.popen('git describe --tags --abbrev=0').read().strip()
if version == '':
version = 'v0.0.0'
elif git_branch.find('develop') != -1 and not (git_branch.find('develop-') >= 0 or git_branch.find('develop/') >= 0):
version = 'latest-develop'
else:
version = 'branch-' + git_branch

# For debugging purpose only
print("GIT BRANCH: " + git_branch)
print("VERSION: " + version)
print("GIT VERSION: " + version)

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -123,7 +128,7 @@
#
#
breathe_projects = {
"lwmem": "_build/xml/"
"lwmem": "_build/xml/"
}
breathe_default_project = "lwmem"
breathe_default_members = ('members', 'undoc-members')
5 changes: 4 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ Welcome to the documentation for version |version|.

LwMEM is lightweight dynamic memory manager optimized for embedded systems.

.. image:: static/images/logo.svg
:align: center

.. rst-class:: center
.. rst-class:: index_links

:ref:`download_library` :ref:`getting_started` `Open Github <https://github.com/MaJerle/lwmem>`_
:ref:`download_library` :ref:`getting_started` `Open Github <https://github.com/MaJerle/lwmem>`_ `Donate <https://paypal.me/tilz0R>`_

Features
^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
breathe>=4.9.1
colorama
docutils>=0.14
sphinx>=2.0.1
docutils==0.16
sphinx>=3.5.1
sphinx_rtd_theme
sphinx-tabs
sphinxcontrib-svg2pdfconverter
Expand Down
1 change: 1 addition & 0 deletions docs/static/images/logo.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2020-12-05T00:19:20.329Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.3.2 Chrome/78.0.3904.113 Electron/7.1.2 Safari/537.36" etag="V0MvXZe_QYE6MFCmOuaH" version="12.3.2" type="device" pages="1"><diagram id="Wsjaadh77UIxB9X1bxos" name="Page-1">jZLLbsMgEEW/xstItkmiZNs0TaUm2WSRNTITgwoei+Di9OuL68EPRZW6gjnzAO4lYTvTHiyv5QkF6CRPRZuw1yTPs3SzCUtHHj3ZrgmUVgkqGsFFfUPsJNooAfdZoUPUTtVzWGBVQeFmjFuLfl52Qz0/teYlPIFLwfUzvSrhZE83q3Tk76BKGU/OUsoYHosJ3CUX6CeI7RO2s4iu35l2B7oTL+rS9739kR0uZqFy/2k4L8QStsYfz6Z5WW4/bvqaLWjKF9cNPfjoT/sT3dg9ogwWm0pANylL2IuXysGl5kWX9cH4wKQzmtJ3Z/FzkGsdyA0rR96yLh60SEPw/JB4K7AO2gmihx0ADTj7CCWUZctV30K/LI+xHz3L1mSEnPgVfeT0Tcph9Khk2JCYMRxN+81Nvj7b/wA=</diagram></mxfile>
3 changes: 3 additions & 0 deletions docs/static/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/lwmem_rtos_stm32l496_discovery/inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef __MAIN_H
#define __MAIN_H
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/lwmem_rtos_stm32l496_discovery/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#include "main.h"
#include "cmsis_os.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/lwmem_stm32l496_discovery/inc/lwmem_opts.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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/lwmem_stm32l496_discovery/inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef __MAIN_H
#define __MAIN_H
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/lwmem_stm32l496_discovery/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#include "main.h"
#include "lwmem/lwmem.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/win32/lwmem/lwmem_opts.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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion examples/win32/lwmem_multi_ins_multi_region/lwmem_opts.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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion examples/win32/lwmem_multi_region/lwmem_opts.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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion examples/win32/lwmem_os/lwmem_opts.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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_H
Expand Down
14 changes: 12 additions & 2 deletions lwmem/src/include/lwmem/lwmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_H
#define LWMEM_HDR_H

#include <string.h>
#include <stdint.h>
#include <limits.h>
#include "lwmem/lwmem_opt.h"
Expand Down Expand Up @@ -67,6 +66,14 @@ typedef struct lwmem_block {
or `0` when block is considered free */
} lwmem_block_t;

/**
* \brief Statistics structure
*/
typedef struct {
uint32_t nr_alloc; /*!< Number of all allocated blocks in single instance */
uint32_t nr_free; /*!< Number of frees in the LwMEM instance */
} lwmem_stats_t;

/**
* \brief LwMEM main structure
*/
Expand All @@ -78,6 +85,9 @@ typedef struct lwmem {
#if LWMEM_CFG_OS || __DOXYGEN__
LWMEM_CFG_OS_MUTEX_HANDLE mutex; /*!< System mutex for OS */
#endif /* LWMEM_CFG_OS || __DOXYGEN__ */
#if LWMEM_CFG_ENABLE_STATS || __DOXYGEN__
lwmem_stats_t stats; /*!< Statistics */
#endif /* LWMEM_CFG_ENABLE_STATS || __DOXYGEN__ */
#if defined(LWMEM_DEV) && !__DOXYGEN__
lwmem_block_t start_block_first_use; /*!< Value of start block for very first time.
This is used only during validation process and is removed in final use */
Expand Down
23 changes: 22 additions & 1 deletion lwmem/src/include/lwmem/lwmem_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
* This file is part of LwMEM - Lightweight dynamic memory manager library.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPT_H
#define LWMEM_HDR_OPT_H

/* Uncomment to ignore user options (or set macro in compiler flags) */
/* #define LWMEM_IGNORE_USER_OPTS */

/* Include application options */
#ifndef LWMEM_IGNORE_USER_OPTS
#include "lwmem_opts.h"
Expand Down Expand Up @@ -82,6 +85,24 @@ extern "C" {
#define LWMEM_CFG_ALIGN_NUM ((size_t)4)
#endif

/**
* \brief Enables `1` or disables `0` memory cleanup on free operation (or realloc).
*
* It resets unused memory to `0x00` and prevents other applications seeing old data.
* It is disabled by default since it has performance penalties.
* /
#ifndef LWMEM_CFG_CLEAN_MEMORY
#define LWMEM_CFG_CLEAN_MEMORY 0
#endif
/**
* \brief Enables `1` or disables `0` statistics in the library
*
*/
#ifndef LWMEM_CFG_ENABLE_STATS
#define LWMEM_CFG_ENABLE_STATS 0
#endif

/**
* \}
*/
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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_OPTS_H
#define LWMEM_HDR_OPTS_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 <[email protected]>
* Version: v1.4.0
* Version: v1.5.0
*/
#ifndef LWMEM_HDR_SYS_H
#define LWMEM_HDR_SYS_H
Expand Down
Loading

0 comments on commit 53e784a

Please sign in to comment.