Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: PlatformIO
# Builds examples/platformio/xallocator-demo for every board in its
# platformio.ini, and runs the native build on the desktop. The example's
# lib_deps points at this checkout, so each push tests the library as
# PlatformIO users consume it (library.json, srcFilter).
# PlatformIO users consume it (library.json, srcFilter). Allocator, a
# dependency in library.json, comes from the PlatformIO registry.

on:
push:
Expand Down
1 change: 1 addition & 0 deletions Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void* Allocator::Allocate(size_t size)
if(m_poolIndex < m_maxObjects)
{
pBlock = (void*)(m_pPool + (m_poolIndex++ * m_blockSize));
m_blockCnt++;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Originally published on CodeProject at: <a href="https://www.codeproject.com/Art
`xallocator` is in the [PlatformIO registry](https://registry.platformio.org/libraries/endurodave/xallocator). Add it to your project's `platformio.ini`:

```ini
lib_deps = endurodave/xallocator@^1.1.0
lib_deps = endurodave/xallocator@^1.2.0
```

Then `#include "xallocator.h"` and use `xmalloc()`/`xfree()` or the `XALLOCATOR` macro. The library needs C++11 and builds on any Arduino core with a C++ standard library (ESP32, STM32, RP2040, ...) and on the desktop (`platform = native`). 8-bit AVR boards are not supported. On an RTOS, add the lock option for your OS, e.g. `build_flags = -DXALLOC_LOCK_FREERTOS`; see [Porting Issues](https://github.com/endurodave/xallocator#porting-issues).
PlatformIO also installs [Allocator](https://registry.platformio.org/libraries/endurodave/Allocator), the fixed block allocator `xallocator` is built on. Then `#include "xallocator.h"` and use `xmalloc()`/`xfree()` or the `XALLOCATOR` macro. The library needs C++11 and builds on any Arduino core with a C++ standard library (ESP32, STM32, RP2040, ...) and on the desktop (`platform = native`). 8-bit AVR boards are not supported. On an RTOS, add the lock option for your OS, e.g. `build_flags = -DXALLOC_LOCK_FREERTOS`; see [Porting Issues](https://github.com/endurodave/xallocator#porting-issues).

The [xallocator-demo](https://github.com/endurodave/xallocator/tree/master/examples/platformio/xallocator-demo) example runs on ESP32, ESP32-C3, STM32 Nucleo-F401RE, STM32F4 Discovery (two FreeRTOS tasks sharing `xallocator` with `XALLOC_LOCK_FREERTOS`), Raspberry Pi Pico and the desktop:

Expand Down
6 changes: 4 additions & 2 deletions examples/platformio/xallocator-demo/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
; pio run -e native -t exec build and run on the desktop
;
; Copying this example into your own project? Change lib_deps to
; lib_deps = endurodave/xallocator@^1.1.0
; (here it points at this repository so every commit is tested).
; lib_deps = endurodave/xallocator@^1.2.0
; (here it points at this repository so every commit is tested). Either way
; Allocator, which manages the fixed blocks, comes from the registry as a
; dependency (see library.json).

[env]
lib_deps = symlink://../../..
Expand Down
9 changes: 6 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xallocator",
"version": "1.1.0",
"version": "1.2.0",
"description": "Fast fixed block memory allocator replacing malloc/free and new/delete. Prevents heap fragmentation; thread-safe; optional static pools for heap-free embedded systems.",
"keywords": ["allocator", "memory", "memory pool", "fixed block", "malloc", "heap", "embedded", "cpp"],
"repository": { "type": "git", "url": "https://github.com/endurodave/xallocator.git" },
Expand All @@ -10,9 +10,12 @@
"frameworks": "*",
"platforms": "*",
"headers": "xallocator.h",
"dependencies": [
{ "owner": "endurodave", "name": "Allocator", "version": "^1.1.0" }
],
"export": {
"include": [
"xallocator.cpp", "xallocator.h", "Allocator.cpp", "Allocator.h",
"xallocator.cpp", "xallocator.h",
"LICENSE", "README.md", "library.json",
"examples/platformio/xallocator-demo/platformio.ini",
"examples/platformio/xallocator-demo/src/main.cpp"
Expand All @@ -21,7 +24,7 @@
"build": {
"srcDir": ".",
"includeDir": ".",
"srcFilter": ["-<*>", "+<xallocator.cpp>", "+<Allocator.cpp>"]
"srcFilter": ["-<*>", "+<xallocator.cpp>"]
},
"examples": [
{
Expand Down
Loading