Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

Commit 693ad03

Browse files
committed
no-throw/thread-safe baseline
1 parent 5955436 commit 693ad03

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,22 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
source-audit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Audit production sources
18+
run: |
19+
if rg -n '\bthrow\b|std::abort\(' src; then
20+
echo "Embedded safety audit failed"
21+
exit 1
22+
fi
23+
1124
build-examples:
1225
runs-on: ubuntu-latest
26+
needs: source-audit
1327
strategy:
1428
fail-fast: false
1529
matrix:

library.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
],
3838
"build": {
3939
"flags": [
40-
"-std=gnu++17"
40+
"-std=gnu++17",
41+
"-fno-exceptions"
4142
]
4243
}
4344
}

src/esp_date/date_allocator.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,12 @@ template <typename T> class DateAllocator {
5353
return nullptr;
5454
}
5555
if (n > (std::numeric_limits<std::size_t>::max() / sizeof(T))) {
56-
#if defined(__cpp_exceptions)
57-
throw std::bad_alloc();
58-
#else
59-
std::abort();
60-
#endif
56+
return nullptr;
6157
}
6258

6359
void *memory = date_allocator_detail::allocate(n * sizeof(T), usePSRAMBuffers_);
6460
if (memory == nullptr) {
65-
#if defined(__cpp_exceptions)
66-
throw std::bad_alloc();
67-
#else
68-
std::abort();
69-
#endif
61+
return nullptr;
7062
}
7163
return static_cast<T *>(memory);
7264
}

0 commit comments

Comments
 (0)