# Message Pool

# Message Pool

This module includes the platform abstraction for the message pool.

## Summary

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1ga2fc2798cbb0a816cde290ddd27659a66` | typedef `struct https://openthread.io/reference/struct/ot-message-buffer` Represents an OpenThread message buffer. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1ga19ead175f68e3a95734787d6be95c28f(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `void` Deinitialize the platform implemented message pool. |
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1gabc9bcfe902b2af80789bddaae0f4fb16(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/struct/ot-message-buffer *aBuffer)` | `void` Is used to free a buffer back to the platform managed buffer pool. |
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1ga2c1c14021785a73591e9cbb8811ade16(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint16_t aMinNumFreeBuffers, size_t aBufferSize)` | `void` Initialize the platform implemented message pool. |
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1ga8e9505388feef9d60a0b9b56761690e3(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/struct/ot-message-buffer *` Allocate a buffer from the platform managed buffer pool. |
| `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1gae03532b717e942b3590ec5804dbd0f5c(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `uint16_t` Get the number of free buffers. |

| ### Structs ||
|---|---|
| [otMessageBuffer](https://openthread.io/reference/struct/ot-message-buffer) | Represents an OpenThread message buffer. |

## Typedefs

### otMessageBuffer

```
struct otMessageBuffer otMessageBuffer
```
Represents an OpenThread message buffer.

## Functions

### otPlatMessagePoolDeinit

```
void otPlatMessagePoolDeinit(
  otInstance *aInstance
)
```
Deinitialize the platform implemented message pool.

Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | |

### otPlatMessagePoolFree

```
void otPlatMessagePoolFree(
  otInstance *aInstance,
  otMessageBuffer *aBuffer
)
```
Is used to free a buffer back to the platform managed buffer pool.

Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | | `[in] aBuffer` | The buffer to free. | |

### otPlatMessagePoolInit

```
void otPlatMessagePoolInit(
  otInstance *aInstance,
  uint16_t aMinNumFreeBuffers,
  size_t aBufferSize
)
```
Initialize the platform implemented message pool.

Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | | `[in] aMinNumFreeBuffers` | An uint16 containing the minimum number of free buffers desired by OpenThread. | | `[in] aBufferSize` | The size in bytes of a buffer object. | |

### otPlatMessagePoolNew

```
otMessageBuffer * otPlatMessagePoolNew(
  otInstance *aInstance
)
```
Allocate a buffer from the platform managed buffer pool.

Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.

The returned buffer instance MUST have at least `aBufferSize` bytes (as specified in `https://openthread.io/reference/group/plat-messagepool#group__plat-messagepool_1ga2c1c14021785a73591e9cbb8811ade16`).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | |
| **Returns** | A pointer to the buffer or NULL if no buffers are available. |

### otPlatMessagePoolNumFreeBuffers

```
uint16_t otPlatMessagePoolNumFreeBuffers(
  otInstance *aInstance
)
```
Get the number of free buffers.

Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | |
| **Returns** | The number of buffers currently free and available to OpenThread. |

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).