summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShell <[email protected]>2024-08-26 11:02:18 +0800
committerMeco Man <[email protected]>2024-08-27 00:48:06 -0400
commitcbf6b641c23c78b6f82dfb51fecebd0f95a60896 (patch)
tree1c5819682f37b59981c2e1e923e99744fb1e8243 /src
parent82f30aa54f67b3be6acadfbd34f68d2971606055 (diff)
feat: add memset zero for rt_thread_init
`rt_object_allocate()` will clear memory after new rt_thread allocate in `rt_thread_create()`. However, in `rt_thread_init()` the same behavior is missing, which corrupt the consistence of the API. Changes: - Added `memset()` zero for `rt_thread_init()` in the entry Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/thread.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c
index 1327c47bbb..eef7a15376 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -334,6 +334,9 @@ rt_err_t rt_thread_init(struct rt_thread *thread,
RT_ASSERT(stack_start != RT_NULL);
RT_ASSERT(tick != 0);
+ /* clean memory data of thread */
+ rt_memset(thread, 0x0, sizeof(struct rt_thread));
+
/* initialize thread object */
rt_object_init((rt_object_t)thread, RT_Object_Class_Thread, name);