Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

void  OSMemPut (OS_MEM  *p_mem,
                void    *p_blk,
                OS_ERR  *p_err)

File

Called from

Code enabled by

os_mem.c

Task or ISR

OS_CFG_MEM_EN

OSMemPut() returns a memory block back to a memory partition. It is assumed that the user will return the memory block to the same memory partition from which it was allocated.

Arguments

p_mem

is a pointer to the memory partition control block.

p_blk

is a pointer to the memory block to be returned to the memory partition.

p_err

is a pointer to a variable that holds an error code:

OS_ERR_NONE

If a memory block is available and returned to the application.

OS_ERR_MEM_INVALID_P_BLK

If OS_CFG_ARG_CHK_EN is set to 1 in os_cfg.h: if the user passed a NULL pointer for the memory block being returned to the memory partition.

OS_ERR_MEM_INVALID_P_MEM

If OS_CFG_ARG_CHK_EN is set to 1 in os_cfg.h: if p_mem is a NULL pointer.

OS_ERR_MEM_MEM_FULL

If returning a memory block to an already full memory partition. This would indicate that the user freed more blocks that were allocated and potentially did not return some of the memory blocks to the proper memory partition.

Returned Value

None

Notes/Warnings

  • Memory partitions must be created before they are used.
  • You must return a memory block to the proper memory partition.
  • You can call this function from an ISR or a task.
  • Example

    • No labels