mm/mm_heap: remove the unnecessary check for memory node size
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
b95022f8de
commit
39eaeefb78
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <nuttx/fs/procfs.h>
|
#include <nuttx/fs/procfs.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -103,12 +104,23 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_MM_SMALL
|
#ifdef CONFIG_MM_SMALL
|
||||||
# define MM_ALLOC_BIT 0x8000
|
# define MM_ALLOC_BIT 0x8000
|
||||||
|
# define MMSIZE_MAX UINT16_MAX
|
||||||
#else
|
#else
|
||||||
# define MM_ALLOC_BIT 0x80000000
|
# define MM_ALLOC_BIT 0x80000000
|
||||||
|
# define MMSIZE_MAX UINT32_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MM_IS_ALLOCATED(n) \
|
#define MM_IS_ALLOCATED(n) \
|
||||||
((int)((FAR struct mm_allocnode_s *)(n)->preceding) < 0)
|
((int)((FAR struct mm_allocnode_s *)(n)->preceding) < 0)
|
||||||
|
|
||||||
|
/* What is the size of the allocnode? */
|
||||||
|
|
||||||
|
#define SIZEOF_MM_ALLOCNODE sizeof(struct mm_allocnode_s)
|
||||||
|
|
||||||
|
/* What is the size of the freenode? */
|
||||||
|
|
||||||
|
#define SIZEOF_MM_FREENODE sizeof(struct mm_freenode_s)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -117,10 +129,8 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_MM_SMALL
|
#ifdef CONFIG_MM_SMALL
|
||||||
typedef uint16_t mmsize_t;
|
typedef uint16_t mmsize_t;
|
||||||
# define MMSIZE_MAX UINT16_MAX
|
|
||||||
#else
|
#else
|
||||||
typedef uint32_t mmsize_t;
|
typedef uint32_t mmsize_t;
|
||||||
# define MMSIZE_MAX UINT32_MAX
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This describes an allocated chunk. An allocated chunk is
|
/* This describes an allocated chunk. An allocated chunk is
|
||||||
@ -134,16 +144,8 @@ struct mm_allocnode_s
|
|||||||
mmsize_t preceding; /* Size of the preceding chunk */
|
mmsize_t preceding; /* Size of the preceding chunk */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* What is the size of the allocnode? */
|
static_assert(SIZEOF_MM_ALLOCNODE <= MM_MIN_CHUNK,
|
||||||
|
"Error size for struct mm_allocnode_s\n");
|
||||||
#ifdef CONFIG_MM_SMALL
|
|
||||||
# define SIZEOF_MM_ALLOCNODE (4)
|
|
||||||
#else
|
|
||||||
# define SIZEOF_MM_ALLOCNODE (8)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CHECK_ALLOCNODE_SIZE \
|
|
||||||
DEBUGASSERT(sizeof(struct mm_allocnode_s) == SIZEOF_MM_ALLOCNODE)
|
|
||||||
|
|
||||||
/* This describes a free chunk */
|
/* This describes a free chunk */
|
||||||
|
|
||||||
@ -155,19 +157,14 @@ struct mm_freenode_s
|
|||||||
FAR struct mm_freenode_s *blink;
|
FAR struct mm_freenode_s *blink;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(SIZEOF_MM_FREENODE <= MM_MIN_CHUNK,
|
||||||
|
"Error size for struct mm_freenode_s\n");
|
||||||
|
|
||||||
struct mm_delaynode_s
|
struct mm_delaynode_s
|
||||||
{
|
{
|
||||||
FAR struct mm_delaynode_s *flink;
|
FAR struct mm_delaynode_s *flink;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* What is the size of the freenode? */
|
|
||||||
|
|
||||||
#define MM_PTR_SIZE sizeof(FAR struct mm_freenode_s *)
|
|
||||||
#define SIZEOF_MM_FREENODE (SIZEOF_MM_ALLOCNODE + 2*MM_PTR_SIZE)
|
|
||||||
|
|
||||||
#define CHECK_FREENODE_SIZE \
|
|
||||||
DEBUGASSERT(sizeof(struct mm_freenode_s) == SIZEOF_MM_FREENODE)
|
|
||||||
|
|
||||||
/* This describes one heap (possibly with multiple regions) */
|
/* This describes one heap (possibly with multiple regions) */
|
||||||
|
|
||||||
struct mm_heap_s
|
struct mm_heap_s
|
||||||
|
@ -182,15 +182,6 @@ FAR struct mm_heap_s *mm_initialize(FAR const char *name,
|
|||||||
heapsize -= sizeof(struct mm_heap_s);
|
heapsize -= sizeof(struct mm_heap_s);
|
||||||
heapstart = (FAR char *)heap_adj + sizeof(struct mm_heap_s);
|
heapstart = (FAR char *)heap_adj + sizeof(struct mm_heap_s);
|
||||||
|
|
||||||
/* The following two lines have cause problems for some older ZiLog
|
|
||||||
* compilers in the past (but not the more recent). Life is easier if we
|
|
||||||
* just the suppress them altogther for those tools.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ZILOG__
|
|
||||||
CHECK_ALLOCNODE_SIZE;
|
|
||||||
CHECK_FREENODE_SIZE;
|
|
||||||
#endif
|
|
||||||
DEBUGASSERT(MM_MIN_CHUNK >= SIZEOF_MM_FREENODE);
|
DEBUGASSERT(MM_MIN_CHUNK >= SIZEOF_MM_FREENODE);
|
||||||
DEBUGASSERT(MM_MIN_CHUNK >= SIZEOF_MM_ALLOCNODE);
|
DEBUGASSERT(MM_MIN_CHUNK >= SIZEOF_MM_ALLOCNODE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user