Function caerEventPacketResize

Function Documentation

static inline caerEventPacketHeader caerEventPacketResize(caerEventPacketHeader packet, int32_t newEventCapacity)

Resize an event packet. First, the packet is cleaned (all invalid events removed), then:

  • If the old and new event capacity are equal, nothing else changes.

  • If the new capacity is bigger, the packet is enlarged and the new events are initialized to all zeros (invalid).

  • If the new capacity is smaller, the packet is truncated at the given point. Use free() to reclaim this memory afterwards.

Parameters:
  • packet – the current event packet.

  • newEventCapacity – the new maximum number of events this packet can hold. Cannot be zero.

Returns:

a valid event packet handle or NULL on error. On success, the old packet handle is to be considered invalid and not to be used anymore. On failure, the old packet handle is still valid, but will have been cleaned of all invalid events!