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>
This commit is contained in:
parent
99ec576096
commit
41037eb265
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue