⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heap.h

📁 开放源码的嵌入式开发环境
💻 H
📖 第 1 页 / 共 2 页
字号:
 *          unsuccessful, 0 will be returned. */uint32_t   _Heap_Initialize(  Heap_Control *the_heap,  void         *starting_address,  uint32_t      size,  uint32_t      page_size);/** *  This routine grows @a the_heap memory area using the size bytes which *  begin at @a starting_address. * *  @param[in] the_heap is the heap to operate upon *  @param[in] starting_address is the starting address of the memory *         to add to the heap *  @param[in] size is the size in bytes of the memory area to add *  @param[in] amount_extended points to a user area to return the *  @return a status indicating success or the reason for failure *  @return *size filled in with the amount of memory added to the heap */Heap_Extend_status _Heap_Extend(  Heap_Control *the_heap,  void         *starting_address,  uint32_t      size,  uint32_t     *amount_extended);/** *  This function attempts to allocate a block of @a size bytes from *  @a the_heap.  If insufficient memory is free in @a the_heap to allocate *  a block of the requested size, then NULL is returned. * *  @param[in] the_heap is the heap to operate upon *  @param[in] size is the amount of memory to allocate in bytes *  @return NULL if unsuccessful and a pointer to the block if successful */void *_Heap_Allocate(  Heap_Control *the_heap,  uint32_t    size);/** *  This function attempts to allocate a memory block of @a size bytes from *  @a the_heap so that the start of the user memory is aligned on the *  @a alignment boundary. If @a alignment is 0, it is set to CPU_ALIGNMENT. *  Any other value of @a alignment is taken "as is", i.e., even odd *  alignments are possible. *  Returns pointer to the start of the memory block if success, NULL if *  failure. * *  @param[in] the_heap is the heap to operate upon *  @param[in] size is the amount of memory to allocate in bytes *  @param[in] alignment the required alignment *  @return NULL if unsuccessful and a pointer to the block if successful */void *_Heap_Allocate_aligned(  Heap_Control *the_heap,  uint32_t    size,  uint32_t    alignment);/** *  This function sets @a *size to the size of the block of user memory *  which begins at @a starting_address. The size returned in @a *size could *  be greater than the size requested for allocation. *  Returns TRUE if the @a starting_address is in the heap, and FALSE *  otherwise. * *  @param[in] the_heap is the heap to operate upon *  @param[in] starting_address is the starting address of the user block *         to obtain the size of *  @param[in] size points to a user area to return the size in *  @return TRUE if successfully able to determine the size, FALSE otherwise *  @return *size filled in with the size of the user area for this block */boolean _Heap_Size_of_user_area(  Heap_Control        *the_heap,  void                *starting_address,  size_t              *size);/** *  This function tries to resize in place the block that is pointed to by the *  @a starting_address to the new @a size. * *  @param[in] the_heap is the heap to operate upon *  @param[in] starting_address is the starting address of the user block *         to be resized *  @param[in] size is the new size *  @param[in] old_mem_size points to a user area to return the size of the *         user memory area of the block before resizing. *  @param[in] avail_mem_size points to a user area to return the size of *         the user memory area of the free block that has been enlarged or *         created due to resizing, 0 if none. *  @return HEAP_RESIZE_SUCCESSFUL if successfully able to resize the block, *          HEAP_RESIZE_UNSATISFIED if the block can't be resized in place, *          HEAP_RESIZE_FATAL_ERROR if failure *  @return *old_mem_size filled in with the size of the user memory area of *          the block before resizing. *  @return *avail_mem_size filled in with the size of the user memory area *          of the free block that has been enlarged or created due to *          resizing, 0 if none. */Heap_Resize_status _Heap_Resize_block(  Heap_Control *the_heap,  void         *starting_address,  uint32_t     size,  uint32_t     *old_mem_size,  uint32_t     *avail_mem_size);/** *  This routine returns the block of memory which begins *  at @a starting_address to @a the_heap.  Any coalescing which is *  possible with the freeing of this routine is performed. * *  @param[in] the_heap is the heap to operate upon *  @param[in] start_address is the starting address of the user block *         to free *  @return TRUE if successfully freed, FALSE otherwise */boolean _Heap_Free(  Heap_Control *the_heap,  void         *start_address);/** *  This routine walks the heap to verify its integrity. * *  @param[in] the_heap is the heap to operate upon *  @param[in] source is a user specified integer which may be used to *         indicate where in the application this was invoked from *  @param[in] do_dump is set to TRUE if errors should be printed *  @return TRUE if the test passed fine, FALSE otherwise. */boolean _Heap_Walk(  Heap_Control *the_heap,  int           source,  boolean       do_dump);/** *  This routine walks the heap and tots up the free and allocated *  sizes. * *  @param[in] the_heap pointer to heap header *  @param[in] the_info pointer to a status information area *  @return *the_info is filled with status information *  @return 0=success, otherwise heap is corrupt. */Heap_Get_information_status _Heap_Get_information(  Heap_Control            *the_heap,  Heap_Information_block  *the_info);/** *  This heap routine returns information about the free blocks *  in the specified heap. * *  @param[in] the_heap pointer to heap header. *  @param[in] info pointer to the free block information. * *  @return free block information filled in. */void _Heap_Get_free_information(  Heap_Control        *the_heap,  Heap_Information    *info);#if !defined(__RTEMS_APPLICATION__)/** *  A pointer to unsigned integer conversion. */#define _H_p2u(_p) ((_H_uptr_t)(_p))#include <rtems/score/heap.inl>/** *  Convert user requested 'size' of memory block to the block size. * *  @note This is an internal routine used by _Heap_Allocate() and *  _Heap_Allocate_aligned().  Refer to 'heap.c' for details. * *  @param[in] size is the size of the block requested *  @param[in] page_size is the page size of this heap instance *  @param[in] min_size is minimum size block that should be allocated *         from this heap instance * *  @return This method returns block size on success, 0 if overflow occured. */extern uint32_t _Heap_Calc_block_size(  uint32_t size,  uint32_t page_size,  uint32_t min_size);/** *  This method allocates a block of size @a alloc_size from @a the_block *  belonging to @a the_heap. Split @a the_block if possible, otherwise *  allocate it entirely.  When split, make the lower part used, and leave *  the upper part free. * *  This is an internal routines used by _Heap_Allocate() and *  _Heap_Allocate_aligned().  Refer to 'heap.c' for details. * *  @param[in] the_heap is the heap to operate upon *  @param[in] the_block is the block to allocates the requested size from *  @param[in] alloc_size is the requested number of bytes to take out of  *         the block * *  @return This methods returns the size of the allocated block. */extern uint32_t _Heap_Block_allocate(  Heap_Control* the_heap,  Heap_Block*   the_block,  uint32_t      alloc_size);/* * Debug support */#if defined(RTEMS_DEBUG)#define RTEMS_HEAP_DEBUG#endif/** *  We do asserts only for heaps with instance number greater than 0 assuming *  that the heap used for malloc is initialized first and thus has instance *  number 0. Asserting malloc heap may lead to troubles as printf may invoke *  malloc thus probably leading to infinite recursion. */#if defined(RTEMS_HEAP_DEBUG)#include <assert.h>#define _HAssert(cond_) \  do { \    if(the_heap->stats.instance && !(cond_)) \      __assert(__FILE__, __LINE__, #cond_);  \  } while(0)#else  /* !defined(RTEMS_HEAP_DEBUG) */#define _HAssert(cond_) ((void)0)#endif /* !defined(RTEMS_HEAP_DEBUG) */#endif /* !defined(__RTEMS_APPLICATION__) */#ifdef __cplusplus}#endif/**@}*/#endif/* end of include file */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -