Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Description

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. Anchor10010381001038 Arguments Anchor10010391001039 p_mem Anchor10010411001041

Files

os.h/os_mem.c

Prototype


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

Arguments

p_mem

is a pointer to the memory partition control block.

...

10010421001042p_blk Anchor10010441001044

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

...

10010451001045p_err Anchor10010461001046

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

...

...

OS_ERR_NONE

...

classWebWorks_Indent_2

...

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

...

classWebWorks_Indent_1

...

OS_ERR_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.

OS_ERR_MEM_INVALID_P_BLK

...

classWebWorks_Indent_2

...

If OS_CFG_ARG_CHK_EN is set to

...

DEF_ENABLED in os_cfg.h: if the user passed a NULL pointer for the memory block being returned to the memory partition.

...

classWebWorks_Indent_1

...

OS_ERR_MEM_INVALID_P_MEM

...

classWebWorks_Indent_2

...

If OS_CFG_ARG_CHK_EN is set to

...

DEF_ENABLED in os_cfg.h: if p_mem is a NULL pointer.

...

classWebWorks_Indent_1

...

classWebWorks_Indent_2

...

OS_ERR_OBJ_TYPE

If OS_CFG_OBJ_TYPE_CHK_EN is set to DEF_ENABLED in os_cfg.h: if the user did not pass a pointer to a memory partition.

Returned Value

None

Required Configuration

OS_CFG_MEM_EN must be enabled in os_cfg.h. Refer to µC-OS-III Configuration Manual.

Callers

Application and ISRs.

Notes/Warnings

  1. Memory partitions must be created before they are used.

...

  1. You must return a memory block to the proper memory partition.

...

...

Example Usage

...

Code Block

...

OS_MEM CommMem; CPU_INT32U *CommMsg;     void Task (void *p_arg) { OS_ERR err;     while

              while (DEF_ON)
{
 {
                  OSMemPut(&CommMem,
(void *)CommMsg, &err); /* Check “err” */ : : } }tr

                           (void *)CommMsg,
                           &err);
                  /* Check "err" */
                  :
                  :
              }
          }
HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan15
Anchor
10523151052315
Anchor
10523161052316
Anchor
10523171052317
Anchor
10523181052318
Anchor
10523191052319
Anchor
10523201052320
Anchor
10523211052321
Anchor
10523221052322
Anchor
10523231052323
Anchor
10523241052324
titleOSMemPut() example usage
          OS_MEM       CommMem;
          CPU_INT32U  *CommMsg;
           
           
          void Task (void *p_arg)
          {
              OS_ERR err;
           
           
              (void)&p_arg;
Anchor
10523251052325
Anchor
10523261052326
Anchor
10523271052327
Anchor
10523281052328
Anchor
10523291052329
Anchor
10523301052330
Anchor
10523311052331
Anchor
10523321052332
Anchor
10523331052333
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)