MSGQ_alloc
Application Program Interface
2-239
C Interface
Syntax
status = MSGQ_alloc(poolId, msg, size);
Parameters
Uint16
poolId;
/* allocate the message from this allocator */
MSGQ_Msg *msg;
/* pointer to the returned message */
Uint16
size;
/* size of the requested message */
Return Value
Int
status;
/* status */
Reentrant
yes
Description
MSGQ_alloc returns a message from the specified allocator. The size is
in minimum addressable data units (MADUs).
This function is performed by a writer. This call is non-blocking and can
be called from a HWI, SWI or TSK.
All messages must be allocated from an allocator. Once a message is
allocated it can be sent. Once a message is received, it must either be
freed or re-used.
The poolId must correspond to one of the allocators specified by the
allocators field of the POOL_Config structure specified by the application.
(See “Static Configuration” on page 2-286.)
If a message is allocated, SYS_OK is returned. Otherwise, SYS_EINVAL
is returned if the poolId is invalid, and SYS_EALLOC is returned if no
memory is available to meet the request.
Constraints and
Calling Context
❏
All message definitions must have MSGQ_MsgHeader as its first
field. For example:
struct MyMsg {
MSGQ_MsgHeader header; /* Required field */
... /* User fields */
}
Example
/* Allocate a message */
status = MSGQ_alloc(STATICPOOLID, (MSGQ_Msg *)&msg,
sizeof(MyMsg));
if (status != SYS_OK) {
SYS_abort("Failed to allocate a message");
}
See Also
MSGQ_alloc
Allocate a message