kernel: mem_domain: optimize sane partition checking
This commit optimizes the process of checking that the added partitions in a mem_domain are sane. It places the sane_partition checking inside the loop of adding the partitions in the mem_domain, so that the checkings are not performed twice, and no partition is checked against itself. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
3e390ed42d
commit
d8b51ea9cd
1 changed files with 5 additions and 7 deletions
|
@ -81,7 +81,7 @@ void k_mem_domain_init(struct k_mem_domain *domain, u8_t num_parts,
|
|||
|
||||
key = irq_lock();
|
||||
|
||||
domain->num_partitions = num_parts;
|
||||
domain->num_partitions = 0;
|
||||
(void)memset(domain->partitions, 0, sizeof(domain->partitions));
|
||||
|
||||
if (num_parts) {
|
||||
|
@ -92,16 +92,14 @@ void k_mem_domain_init(struct k_mem_domain *domain, u8_t num_parts,
|
|||
__ASSERT((parts[i]->start + parts[i]->size) >
|
||||
parts[i]->start, "");
|
||||
|
||||
domain->partitions[i] = *parts[i];
|
||||
}
|
||||
|
||||
#if defined(CONFIG_EXECUTE_XOR_WRITE)
|
||||
for (i = 0; i < num_parts; i++) {
|
||||
__ASSERT(sane_partition_domain(domain,
|
||||
&domain->partitions[i]),
|
||||
parts[i]),
|
||||
"");
|
||||
}
|
||||
#endif
|
||||
domain->partitions[i] = *parts[i];
|
||||
domain->num_partitions++;
|
||||
}
|
||||
}
|
||||
|
||||
sys_dlist_init(&domain->mem_domain_q);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue