diff options
author | Chao Du <duchao@eswincomputing.com> | 2023-03-22 06:51:51 +0000 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-04-07 21:44:31 +0000 |
commit | 41037eb26585114209c3c8f1d63f7788a421df07 (patch) | |
tree | 830d9d54b45bd7dc80a2f2a760c5e64e6ef674f6 /src | |
parent | 99ec5760961d264599a9c9fb1a4d5d6042bc3ba8 (diff) | |
download | riscv-openocd-41037eb26585114209c3c8f1d63f7788a421df07.zip riscv-openocd-41037eb26585114209c3c8f1d63f7788a421df07.tar.gz riscv-openocd-41037eb26585114209c3c8f1d63f7788a421df07.tar.bz2 |
rtos/FreeRTOS: some optimization of freertos_update_threads()
1.
update the rtos->thread_count in time, to make sure the allocated
thread_name_str and extra_info_str could be freed by
rtos_free_threadlist(). Otherwise the abnormal return may cause a
memory leak.
2.
remove a redundant assignment to threadid.
Signed-off-by: Chao Du <duchao@eswincomputing.com>
Change-Id: Ifabc59d501c925b3d6aec8b04b2856d2c31cc4e2
Reviewed-on: https://review.openocd.org/c/openocd/+/7549
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rtos/FreeRTOS.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 070275f..e8df030 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -312,7 +312,6 @@ static int freertos_update_threads(struct rtos *rtos) (list_elem_ptr != prev_list_elem_ptr) && (tasks_found < thread_list_size)) { /* Get the location of the thread structure. */ - rtos->thread_details[tasks_found].threadid = 0; retval = target_read_u32(rtos->target, list_elem_ptr + param->list_elem_content_offset, &pointer_casts_are_bad); @@ -365,6 +364,7 @@ static int freertos_update_threads(struct rtos *rtos) tasks_found++; list_thread_count--; + rtos->thread_count = tasks_found; prev_list_elem_ptr = list_elem_ptr; list_elem_ptr = 0; @@ -383,7 +383,6 @@ static int freertos_update_threads(struct rtos *rtos) } free(list_of_lists); - rtos->thread_count = tasks_found; return 0; } |