fix gran_alloc() miss allocation in mm_granalloc.c.

This commit is contained in:
minabeoki 2020-01-30 23:19:29 +09:00 committed by Alan Carvalho de Assis
parent b80fb6befc
commit 1600980a82

View File

@ -105,8 +105,6 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
/* Now search the granule allocation table for that number of contiguous */ /* Now search the granule allocation table for that number of contiguous */
alloc = priv->heapstart;
for (granidx = 0; granidx < priv->ngranules; granidx += 32) for (granidx = 0; granidx < priv->ngranules; granidx += 32)
{ {
/* Get the GAT index associated with the granule table entry */ /* Get the GAT index associated with the granule table entry */
@ -118,7 +116,6 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
if (curr == 0xffffffff) if (curr == 0xffffffff)
{ {
alloc += (32 << priv->log2gran);
continue; continue;
} }
@ -147,6 +144,8 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
* granules left to satisfy the allocation. * granules left to satisfy the allocation.
*/ */
alloc = priv->heapstart + (granidx << priv->log2gran);
for (bitidx = 0; for (bitidx = 0;
bitidx < 32 && (granidx + bitidx + ngranules) <= priv->ngranules; bitidx < 32 && (granidx + bitidx + ngranules) <= priv->ngranules;
) )