فهرست منبع

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 <smokewood@qq.com>
Shell 11 ماه پیش
والد
کامیت
cbf6b641c2
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      src/thread.c

+ 3 - 0
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);