You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/23 05:19:46 UTC
[incubator-nuttx] branch master updated: mm_size2ndx: using flsl to calculate the ndx
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f7dec2c250 mm_size2ndx: using flsl to calculate the ndx
f7dec2c250 is described below
commit f7dec2c250a2c35da320ec9083f03268add28282
Author: wangbowen6 <wa...@xiaomi.com>
AuthorDate: Wed Nov 23 00:13:38 2022 +0800
mm_size2ndx: using flsl to calculate the ndx
Signed-off-by: wangbowen6 <wa...@xiaomi.com>
---
mm/mm_heap/mm_size2ndx.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/mm/mm_heap/mm_size2ndx.c b/mm/mm_heap/mm_size2ndx.c
index 5d0f9fa2a7..73dad34cc5 100644
--- a/mm/mm_heap/mm_size2ndx.c
+++ b/mm/mm_heap/mm_size2ndx.c
@@ -24,6 +24,8 @@
#include <nuttx/config.h>
+#include <string.h>
+
#include <nuttx/mm/mm.h>
#include "mm_heap/mm.h"
@@ -42,19 +44,11 @@
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;
}