void *OSMemGet (OS_MEM *p_mem,
OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task or ISR |
|
...
Description
Obtains a memory block from a memory partition. It is assumed that the application knows the size of each memory block obtained. Also, the application must return the memory block [using OSMemPut()
] to the same memory partition when it no longer requires it. OSMemGet()
may be called more than once until all memory blocks are allocated.
Files
os.h/os_mem.c
Prototype
Arguments
p_mem
is a pointer to the desired memory partition control block.
...
OSMemGet()
returns a pointer to the allocated memory block if one is available. If a memory block is not available from the memory partition, OSMemGet()
returns a NULL
pointer. It is up to the application to “cast” the pointer to the proper data type since OSMemGet()
returns a void *
.
Required Configuration
OS_CFG_MEM_EN
must be enabled in os_cfg.h. Refer to uC-OS-III Configuration Manual
Notes/Warnings
- Memory partitions must be created before they are used.
- This is a non-blocking call and this function can be called from an ISR.