mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
mm/mempool: fix bug about size mismatch and binary find
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
+14
-11
@@ -99,19 +99,22 @@ int mempool_init(FAR struct mempool_s *pool, FAR const char *name)
|
||||
sq_init(&pool->elist);
|
||||
|
||||
count = pool->ninitial + pool->ninterrupt;
|
||||
base = mempool_malloc(pool, sizeof(*base) +
|
||||
pool->bsize * count);
|
||||
if (base == NULL)
|
||||
if (count != 0)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
base = mempool_malloc(pool, sizeof(*base) +
|
||||
pool->bsize * count);
|
||||
if (base == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sq_addfirst(base, &pool->elist);
|
||||
mempool_add_list(&pool->ilist, base + 1,
|
||||
pool->ninterrupt, pool->bsize);
|
||||
mempool_add_list(&pool->list, (FAR char *)(base + 1) +
|
||||
pool->ninterrupt * pool->bsize,
|
||||
pool->ninitial, pool->bsize);
|
||||
sq_addfirst(base, &pool->elist);
|
||||
mempool_add_list(&pool->ilist, base + 1,
|
||||
pool->ninterrupt, pool->bsize);
|
||||
mempool_add_list(&pool->list, (FAR char *)(base + 1) +
|
||||
pool->ninterrupt * pool->bsize,
|
||||
pool->ninitial, pool->bsize);
|
||||
}
|
||||
|
||||
if (pool->wait && pool->nexpand == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user