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

📄 dmce.c

📁 test file nucleus source
💻 C
📖 第 1 页 / 共 2 页
字号:
/*                        resulting in version 1.1                       *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  DMCE_Delete_Memory_Pool(NU_MEMORY_POOL *pool_ptr){DM_PCB         *pool;                       /* Pool control block ptr    */STATUS          status;                     /* Completion status         */        /* Move input pool pointer into internal pointer.  */    pool =  (DM_PCB *) pool_ptr;    /* Determine if the dynamic memory pool pointer is valid.  */    if ((pool) && (pool -> dm_id == DM_DYNAMIC_ID))            /* Dynamic memory pool pointer is valid, call the function to            delete it.  */        status =  DMC_Delete_Memory_Pool(pool_ptr);            else            /* Dynamic memory pool pointer is invalid, indicate in            completion status. */        status =  NU_INVALID_POOL;            /* Return completion status.  */    return(status);}/*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      DMCE_Allocate_Memory                                             *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function performs error checking on the parameters supplied *//*      to the allocate memory function.                                 *//*                                                                       *//* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      DMC_Allocate_Memory                 Actual memory allocation     *//*                                            function                   *//*      TCCE_Suspend_Error                  Check for suspension error   *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      pool_ptr                            Memory pool pointer          *//*      return_pointer                      Pointer to the destination   *//*                                            memory pointer             *//*      size                                Number of bytes requested    *//*      suspend                             Suspension option if full    *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_INVALID_POOL                     Indicates the supplied pool  *//*                                            pointer is invalid         *//*      NU_INVALID_POINTER                  Indicates the return pointer *//*                                            is NULL                    *//*      NU_INVALID_SIZE                     Indicates the size is 0 or   *//*                                            larger than the pool       *//*      NU_INVALID_SUSPEND                  Invalid suspension requested *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      03-01-1994      Modified function interface                ,     *//*                        resulting in version 1.1                       *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  DMCE_Allocate_Memory(NU_MEMORY_POOL *pool_ptr, VOID **return_pointer,                                        UNSIGNED size, UNSIGNED suspend){DM_PCB         *pool;                       /* Pool control block ptr    */STATUS          status;                     /* Completion status         */    /* Move input pool pointer into internal pointer.  */    pool =  (DM_PCB *) pool_ptr;    /* Determine if dynamic memory pool pointer is invalid.  */    if (pool == NU_NULL)            /* Dynamic memory pool pointer is invalid, indicate in            completion status. */        status =  NU_INVALID_POOL;    else if (pool -> dm_id != DM_DYNAMIC_ID)            /* Dynamic memory pool pointer is invalid, indicate in            completion status. */        status =  NU_INVALID_POOL;    else if (return_pointer == NU_NULL)        /* Return pointer is invalid.  */        status =  NU_INVALID_POINTER;            else if ((size == 0) ||         (size > (pool -> dm_pool_size - (2 * DM_OVERHEAD))))                /* Return the invalid size error.  */        status =  NU_INVALID_SIZE;    else if ((suspend) && (TCCE_Suspend_Error()))            /* Suspension from an non-task thread.  */        status =  NU_INVALID_SUSPEND;    else             /* Parameters are valid, call actual function.  */        status = DMC_Allocate_Memory(pool_ptr, return_pointer, size, suspend);    /* Return the completion status.  */    return(status);}/*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      DMCE_Deallocate_Memory                                           *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function performs error checking on the parameters supplied *//*      to the deallocate memory function.                               *//*                                                                       *//* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      DMC_Deallocate_Memory               Actual deallocate memory     *//*                                            function                   *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      memory                              Pointer to dynamic memory    *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_INVALID_POINTER                  Indicates the supplied       *//*                                            pointer is invalid         *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      03-01-1994      Modified function interface,                     *//*                        resulting in version 1.1                       *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  DMCE_Deallocate_Memory(VOID *memory){DM_PCB         *pool;                       /* Pool pointer              */DM_HEADER      *header_ptr;                 /* Pointer to memory block   */STATUS          status;                     /* Completion status         */    /* Pickup the associated pool's pointer.  It is inside the header of       each memory block.  */    header_ptr =  (DM_HEADER *) (((BYTE_PTR) memory) - DM_OVERHEAD);            /* Determine if the pointer(s) are NULL.  */    if ((header_ptr == NU_NULL) || (memory == NU_NULL))            /* Dynamic memory pointer is invalid.  */        status =  NU_INVALID_POINTER;    /* Determine if dynamic memory pool pointer is invalid.  */    else if ((pool =  header_ptr -> dm_memory_pool) == NU_NULL)            /* Dynamic memory pointer is invalid, indicate in completion            status.  */        status =  NU_INVALID_POINTER;    else if (pool -> dm_id != DM_DYNAMIC_ID)            /* Dynamic memory pool pointer is invalid, indicate in completion            status. */        status =  NU_INVALID_POINTER;            else if (header_ptr -> dm_memory_free)            /* Dynamic memory is free - must not be allocated.  */        status =  NU_INVALID_POINTER;    else             /* Parameters are valid, call actual function.  */        status =  DMC_Deallocate_Memory(memory);    /* Return the completion status.  */    return(status);}

⌨️ 快捷键说明

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