mm_size2ndx: using flsl to calculate the ndx
#include <nuttx/config.h>
+#include <string.h>
+
#include <nuttx/mm/mm.h>
#include "mm_heap/mm.h"
int mm_size2ndx(size_t size)
{
- int ndx = 0;
-
if (size >= MM_MAX_CHUNK)
{
return MM_NNODES - 1;
}
size >>= MM_MIN_SHIFT;
- while (size > 1)
- {
- ndx++;
- size >>= 1;
- }
-
- return ndx;
+ return flsl(size) - 1;
}
