TutBufAllocAligned


Name

TutBufAllocAligned — allocate space in a T_BUF object

Synopsis

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

Arguments

buf — T_BUF object in which to allocate the space

size — number of bytes to allocate

align — alignment factor

Return Values

Pointer to the allocated memory block if successful, NULL otherwise.

Diagnostics

None

Description

TutBufAllocAligned moves the "write pointer" in the T_BUF object to make space for a block of data. This block of data is to be copied into the buffer directly. The buffer grows, if required, to accommodate the space. The alignment factor is used to ensure that this new block ends on a valid boundary (say, 8 bytes), and the "write pointer" is rounded up so that the end of this block is aligned to this boundary.

Caution

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

See Also

TutBufNextAligned

Examples

This example allocates a block 10 bytes long that ends on an 8-byte boundary:

T_PTR ptr; 
ptr = TutBufAllocAligned(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