Skip to content

Commit afbcb12

Browse files
author
Jyri Sarha
committed
module_adapter: generic: Clean up and optimize mod_free_all()
Rewrite misleading copy-pasted comment and remove unnecessary container removals from res->res_list and res->cont_chunk_list. All the containers are anyway freed when the container chunks are freed and the list heads are reinitialized when mod_resource_init() is called. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 79f5155 commit afbcb12

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/audio/module_adapter/module/generic.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -620,22 +620,20 @@ void mod_free_all(struct processing_module *mod)
620620
struct list_item *_list;
621621

622622
MEM_API_CHECK_THREAD(res);
623-
/* Find which container keeps this memory */
624-
list_for_item_safe(list, _list, &res->res_list) {
623+
/* Free all contents found in used containers */
624+
list_for_item(list, &res->res_list) {
625625
struct module_resource *container =
626626
container_of(list, struct module_resource, list);
627627

628628
free_contents(mod, container);
629-
list_item_del(&container->list);
630-
}
631-
632-
list_for_item_safe(list, _list, &res->free_cont_list) {
633-
struct module_resource *container =
634-
container_of(list, struct module_resource, list);
635-
636-
list_item_del(&container->list);
637629
}
638630

631+
/*
632+
* We do not need to remove the containers from res_list in
633+
* the loop above or go through free_cont_list as all the
634+
* containers are anyway freed in the loop below, and the list
635+
* heads are reinitialized when mod_resource_init() is called.
636+
*/
639637
list_for_item_safe(list, _list, &res->cont_chunk_list) {
640638
struct container_chunk *chunk =
641639
container_of(list, struct container_chunk, chunk_list);

0 commit comments

Comments
 (0)