Skip to content

Commit 6b9980d

Browse files
author
Jyri Sarha
committed
modules: Add mod_zalloc() function
Add mod_zalloc() function that is otherwise the same as mod_alloc(), but allocated memory is initialized to zero. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent ffd605c commit 6b9980d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/audio/module_adapter/module/generic.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ void *mod_alloc(struct processing_module *mod, uint32_t size, uint32_t alignment
147147
return ptr;
148148
}
149149

150+
void *mod_zalloc(struct processing_module *mod, uint32_t size, uint32_t alignment)
151+
{
152+
void *ret = mod_alloc(mod, size, alignment);
153+
154+
if (ret)
155+
memset(ret, 0, size);
156+
157+
return ret;
158+
}
159+
150160
int mod_free(struct processing_module *mod, void *ptr)
151161
{
152162
struct module_memory *mem;

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct module_processing_data {
154154
int module_load_config(struct comp_dev *dev, const void *cfg, size_t size);
155155
int module_init(struct processing_module *mod);
156156
void *mod_alloc(struct processing_module *mod, uint32_t size, uint32_t alignment);
157+
void *mod_zalloc(struct processing_module *mod, uint32_t size, uint32_t alignment);
157158
int mod_free(struct processing_module *mod, void *ptr);
158159
void module_free_all_memory(struct processing_module *mod);
159160
int module_prepare(struct processing_module *mod,

0 commit comments

Comments
 (0)