Skip to content

Commit

Permalink
MDRC: Improve Resource Cleanup in multiband_drc_free
Browse files Browse the repository at this point in the history
- Added comprehensive documentation for multiband_drc_free function,
  detailing its purpose, parameters, and the cleanup process.
- Introduced validation to check if component data (`cd`) is not NULL
  before freeing associated resources.
- Ensured all allocated resources are properly freed, and nullified
  the private module data pointer upon cleanup.
- Provided clear log messages indicating the start and successful
  completion of the free operation.
- Included necessary comments to clarify code intent and improve
  maintainability.

Signed-off-by: Shriram Shastry <[email protected]>
  • Loading branch information
ShriramShastry committed Aug 18, 2024
1 parent d7ec648 commit fb011df
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,34 @@ static int multiband_drc_init(struct processing_module *mod)
return ret;
}

/**
* @brief Free resources allocated by Multiband DRC processing component.
*
* This function releases all memory and resources associated with the
* multiband DRC component's operation. This includes dynamically allocated
* filter state instances as well as freeing up the model handler.
*
* @param[in] mod Pointer to the processing module to be freed.
*
* @return 0 indicating success.
*/
static int multiband_drc_free(struct processing_module *mod)
{
struct multiband_drc_comp_data *cd = module_get_private_data(mod);

comp_info(mod->dev, "multiband_drc_free()");

comp_data_blob_handler_free(cd->model_handler);
if (cd) {
/* Freeing other resources as part of the component data */
comp_data_blob_handler_free(cd->model_handler);

/* Free the main component data structure */
rfree(cd);

/* Clear the private module data pointer */
module_set_private_data(mod, NULL);
}

rfree(cd);
return 0;
}

Expand Down

0 comments on commit fb011df

Please sign in to comment.