diff --git a/mm/mm_gran/mm_granalloc.c b/mm/mm_gran/mm_granalloc.c index 30794cd681..be11d0f7af 100644 --- a/mm/mm_gran/mm_granalloc.c +++ b/mm/mm_gran/mm_granalloc.c @@ -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 */ - alloc = priv->heapstart; - for (granidx = 0; granidx < priv->ngranules; granidx += 32) { /* 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) { - alloc += (32 << priv->log2gran); continue; } @@ -147,6 +144,8 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size) * granules left to satisfy the allocation. */ + alloc = priv->heapstart + (granidx << priv->log2gran); + for (bitidx = 0; bitidx < 32 && (granidx + bitidx + ngranules) <= priv->ngranules; )