[Previous] [Contents] [Index] [Next]

PhGetMsgSize()

Get message size

Synopsis:

unsigned PhGetMsgSize( PhEvent_t const *event_buf );

Description:

This function returns the size of buffer necessary to contain the event that couldn't fit into the current buffer. You typically use this function after PhEventRead(), PhEventPeek(), or PhEventNext() has returned a value of Ph_RESIZE_MSG.

These functions can return Ph_RESIZE_MSG only if the application set the Ph_DYNAMIC_BUFFER flag when it attached the Photon channels; see PhAttach().

Returns:

The size of the buffer required to accommodate the entire event.

Examples:

The following fragment shows how you can use PhGetMsgSize() to maintain a dynamic event buffer:

PhEvent_t   *event_buf;
unsigned    event_buf_size;
case Ph_EVENT_MSG:
     PtEventHandler( event_buf ); 
     break;
case Ph_RESIZE_MSG:
     event_buf_size = PhGetMsgSize( event_buf );
     if( !( event_buf = realloc( event_buf, 
                                 event_buf_size ) ) )
     {
          errno = ENOMEM;
          return( -1 ); 
     }
     break;

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhAttach(), PhEventNext(), PhEventPeek(), PhEventRead()


[Previous] [Contents] [Index] [Next]