From 3eedb4356d52e4cde3959082a84826d2db43486a Mon Sep 17 00:00:00 2001 From: Izidor M Date: Sun, 17 Mar 2024 13:15:41 +0000 Subject: [PATCH] Adding .gitignore and README.md update --- .github/workflows/c-cpp.yml | 7 ------- .gitignore | 1 + README.md | 32 +++++++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index ff07a27..a43ae62 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -24,10 +24,3 @@ jobs: cd unit_tests git clone https://github.com/ThrowTheSwitch/Unity.git make clean; make -j4 TOOLS_DIR=./ BUILD_DIR=build/ - -# - name: Checkout Unity repo -# run: ls -l; git clone https://github.com/ThrowTheSwitch/Unity.git -# - name: Check where we are -# run: ls -l -# - name: Make and run -# run: make clean; make -j4 TOOLS_DIR=./ BUILD_DIR=build/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6629726 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +usage_example.c \ No newline at end of file diff --git a/README.md b/README.md index 22f7d40..acd35dc 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@ -# memory allocator -Simple implementation of a memory allocator. It provides overflow detection by enclosing each block with canary values. It doesnt provide memory free functionality. Its purpose is to substitute normal static memory allocation in embedded systems and provide some additional benefits which are hard to get when using static memory allocation. It provides locking mechanism that can be used to prevent using memory allocation after system initialization is done. +# runtime static memory allocator +Simple implementation of a run-time static memory allocator. It +provides overflow detection by enclosing each block with canary +values. It looks like dynamic memory allocator, but it doesn't provide +memory free functionality and it works on user provided memory array +instead of the heap. It's purpose is to substitute normal compiler +based static memory allocation in embedded systems and provide some +additional benefits which are hard to get otherwise: + +- memory overflow protection by adding canary values +- simplifying the use of different ram types in the system + ## Features * Written in C -* Small and efficint code base +* Small and efficient code base * Provides locking of memory allocation * Support for multiple instances in case system offers different ram sections * BSD license ## Usage -Memory allocator needs to be initialized before use, so we can have multiple instances if needed. +Memory allocator needs to be initialized before use, so we can have +multiple instances if needed. ### Simple usage when only one allocator is needed ``` c @@ -31,7 +42,6 @@ void *my_malloc(size_t size) return mem_allocator_malloc_static(m, size); } - ``` ### Usage when there are different sections of ram @@ -111,6 +121,18 @@ solve with this library: 3. Inefficient memory sectioning: With microcontrollers (MCUs) that have RAM divided into different sections (fast RAM, normal RAM, etc.), static memory allocation requires detailed configuration and tweaking of linker scripts to determine allocation of variables to different memory sections. +## Implementation details + +So the idea is to use the dynamic memory allocation during system +initialization phase and then lock it when the system transition in +to the running phase. Because we only use it when initializing the +system we don't need to implement the memory releasing functionality, +because it will never be used. This way we avoid dealing with memory +fragmentation. We also implement locking functionality and error +callback, so if our malloc fail because of locked memory or running +out of ram, the provided error callback will be called, so + + ## Contribute Everybody is welcome to contribute.