Skip to content

Commit 69b7323

Browse files
author
Pierluigi Petrelli
committed
fixing a crash when the TImer is full
1 parent ebd9e90 commit 69b7323

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,6 @@ Currently only a software timer. Any blocking code delaying *timer*.**tick()** w
136136
137137
The library does not do any dynamic memory allocation.
138138
139-
The number of concurrent tasks is a compile time constant, meaning there is a limit to the number of concurrent tasks. The **in / at / every** functions return **false** if the *Timer* is full.
139+
The number of concurrent tasks is a compile time constant, meaning there is a limit to the number of concurrent tasks. The **in / at / every** functions return id **0** if the *Timer* is full.
140140
141141
Change the number of concurrent tasks using the *Timer* constructors. Save memory by reducing the number, increase memory use by having more. The default is **TIMER_MAX_TASKS** which is currently 16.

src/timer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@ class Timer {
165165
{
166166
struct task * const slot = next_task_slot();
167167

168-
if (!slot) return NULL;
168+
if (!slot)
169+
slot->id = random(2147483646);
170+
else
171+
slot->id = 0;
169172

170-
slot->id = random(2147483646);
171173
slot->handler = h;
172174
slot->opaque = opaque;
173175
slot->start = start;

0 commit comments

Comments
 (0)