create_message

3

create_message

allocates and initializes message

    #include <cds/msg_queue.h>

      int create_message
      void *data
      int data_len

## Description

Allocates message using `cds_malloc` and initializes its content so it will be freed automatically. Pointer to the explicitly allocated data is set to `data` and its length is set to `data_len`. Message created by `create_message` should be freed using `message_free`.

Unremoved messages created this way are freed automatically in `msg_queue_destroy` using `free_message`.

Calling `free_message` to such message frees the message and the data given by parameter `data` too, thus they can NOT be freed by the caller!

## Return value

Returns NULL on error, pointer to initialized message structure otherwise.

## See Also

create_message_ex, init_message_ex