Versions Compared

Key

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

Application code can request a memory block from a partition by calling OSMemGet() as shown in Listing 17-3. The code assumes that the partition was already created.

(1) The memory partition control block must be accessible by all tasks or ISRs that will be using the partition.

(2) Simply call OSMemGet() to obtain a memory block from the desired partition. A pointer to the allocated memory block is returned. This is similar to malloc(), except that the memory block comes from a pool that is guaranteed to not fragment. Also, it’s assumed that your application knows the size of each block so it doesn’t overflow the block with data.

(3) It is important to examine the returned error code to ensure that there are free memory blocks and that the application can start putting content in the memory blocks.