TutBufNextAligned


Name

TutBufNextAligned — reserve space in a T_BUF object

Synopsis

T_PTR TutBufNextAligned(buf, size, align) 
T_BUF buf; 
T_INT4 size; 
T_INT4 align; 

Arguments

buf — T_BUF object in which to reserve the space

size — number of bytes to reserve

align — alignment factor

Return Values

Pointer to the memory block at the current position if successful; NULL otherwise.

Diagnostics

None

Description

TutBufNextAligned returns the current position in the T_BUF object to you, and then moves the current position to reserve the requested space. The new position is size bytes past the current position you started with, rounded up to align it with the given alignment factor.

Caution

The returned pointer is only valid until the next call to a buffer operation that may resize the buffer, because the buffer may be moved during a resize.

See Also

TutBufAllocAligned

Examples

This example moves the read index 10 bytes forward, ending on an 8-byte boundary:

T_PTR ptr; 
ptr = TutBufNextAligned(buf, 10, 8); 
if (ptr == NULL) { 
  /* error */ 
} 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com