packet: Introduce pa_packet_new_data() to copy data into a newly created packet

v2: (thanks Alexander Patrakov)
* turn check in pa_packet_new() into assert()

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
This commit is contained in:
Peter Meerwald 2014-10-23 16:51:08 +02:00 committed by Peter Meerwald
parent c1a7f0e326
commit f92300cc92
3 changed files with 16 additions and 1 deletions

View file

@ -29,6 +29,10 @@ typedef struct pa_packet pa_packet;
* on length) */
pa_packet* pa_packet_new(size_t length);
/* create packet (either of type appended or dynamic depending on length)
* and copy data */
pa_packet* pa_packet_new_data(const void* data, size_t length);
/* data must have been malloc()ed; the packet takes ownership of the memory,
* i.e. memory is free()d with the packet */
pa_packet* pa_packet_new_dynamic(void* data, size_t length);