Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d30fea9b
Commit
d30fea9b
authored
May 15, 2015
by
Vowstar
Browse files
Merge pull request #413 from dnc40085/dev096-tmr.alarm_memory_leak_fix
Fix for issue #382
parents
a5d96f47
894fcc47
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/tmr.c
View file @
d30fea9b
...
...
@@ -11,11 +11,18 @@
static
os_timer_t
alarm_timer
[
NUM_TMR
];
static
int
alarm_timer_cb_ref
[
NUM_TMR
]
=
{
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
};
static
bool
alarm_timer_repeat
[
NUM_TMR
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
void
alarm_timer_common
(
lua_State
*
L
,
unsigned
id
){
if
(
alarm_timer_cb_ref
[
id
]
==
LUA_NOREF
)
return
;
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
alarm_timer_cb_ref
[
id
]);
if
(
alarm_timer_repeat
[
id
]
==
0
)
{
if
(
alarm_timer_cb_ref
[
id
]
!=
LUA_NOREF
)
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
alarm_timer_cb_ref
[
id
]);
}
lua_call
(
L
,
0
,
0
);
}
...
...
@@ -118,6 +125,7 @@ static int tmr_alarm( lua_State* L )
stack
++
;
if
(
repeat
!=
1
&&
repeat
!=
0
)
return
luaL_error
(
L
,
"wrong arg type"
);
alarm_timer_repeat
[
id
]
=
repeat
;
}
// luaL_checkanyfunction(L, stack);
...
...
@@ -141,6 +149,9 @@ static int tmr_stop( lua_State* L )
MOD_CHECK_ID
(
tmr
,
id
);
os_timer_disarm
(
&
(
alarm_timer
[
id
]));
if
(
alarm_timer_cb_ref
[
id
]
!=
LUA_NOREF
)
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
alarm_timer_cb_ref
[
id
]);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment