#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#ifdef ALSA_UCM_DEBUG_TIME
#include <sys/time.h>
#include <time.h>
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
if (old_dev_count > 0) {
- dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count);
- for (i = 0; i < old_dev_count; i++) {
- dis_dev_list[i] = NULL;
- }
+ dis_dev_list = (const char **)calloc(old_dev_count, sizeof(const char *));
+ assert(dis_dev_list);
}
if (dev_count > 0) {
- ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count);
- for (i = 0; i < dev_count; i++) {
- ena_dev_list[i] = NULL;
- }
+ ena_dev_list = (const char **)calloc(dev_count, sizeof(const char *));
+ assert(ena_dev_list);
}
if (old_mod_count > 0) {
- dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count);
- for (i = 0; i < old_mod_count; i++) {
- dis_mod_list[i] = NULL;
- }
+ dis_mod_list = (const char **)calloc(old_mod_count, sizeof(const char *));
+ assert(dis_mod_list);
}
if (mod_count > 0) {
- ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count);
- for (i = 0; i < mod_count; i++) {
- ena_mod_list[i] = NULL;
- }
+ ena_mod_list = (const char **)calloc(mod_count, sizeof(const char *));
+ assert(ena_mod_list);
}
/* update disable modifiers list which are not present in new modifier list */
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
if (old_dev_count > 0) {
- dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count);
- for (i = 0; i < old_dev_count; i++) {
- dis_dev_list[i] = NULL;
- }
+ dis_dev_list = (const char **)calloc(old_dev_count, sizeof(const char *));
+ assert(dis_dev_list);
}
if (dev_count > 0) {
- ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count);
- for (i = 0; i < dev_count; i++) {
- ena_dev_list[i] = NULL;
- }
+ ena_dev_list = (const char **)calloc(dev_count, sizeof(const char *));
+ assert(ena_dev_list);
}
/* update disable devices list which are not present in new device list */
AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
if (old_mod_count > 0) {
- dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count);
- for (i = 0; i < old_mod_count; i++) {
- dis_mod_list[i] = NULL;
- }
+ dis_mod_list = (const char **)calloc(old_mod_count, sizeof(const char *));
+ assert(dis_mod_list);
}
if (mod_count > 0) {
- ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count);
- for (i = 0; i < mod_count; i++) {
- ena_mod_list[i] = NULL;
- }
+ ena_mod_list = (const char **)calloc(mod_count, sizeof(const char *));
+ assert(ena_mod_list);
}
/* update disable modifiers list which are not present in new modifier list */
}
return ret;
-}
\ No newline at end of file
+}