Allocates a library structure.
Transport Layer Interface Library (libtli.a)
#include <tiuser.h>
char *t_alloc (fd, struct_type, fields)
int fd;
int struct_type;
int fields;
The t_alloc subroutine dynamically assigns memory for the various transport-function argument structures. This subroutine allocates memory for the specified structure, and also allocates memory for buffers referenced by the structure.
Use of the t_alloc subroutine to allocate structures will help ensure the compatibility of user programs with future releases of the transport interface.
Item | Description |
---|---|
fd | Specifies the transport end point through which the newly allocated structure will be passed. |
struct_type | Specifies the structure to be allocated. The structure to
allocate is specified by the struct_type parameter, and can
be one of the following:
Each of these structures may subsequently be used as a parameter to one or more transport functions. Each of the above structures, except T_INFO, contains at least one field of the struct netbuf type. The netbuf structure is described in the tiuser.h file. For each field of this type, the user may specify that the buffer for that field should be allocated as well. The fields parameter specifies this option, where the parameter is the bitwise-OR of any of the following:
|
fields | Specifies whether the buffer should be allocated for each field type. For each field specified in the fields parameter, the t_alloc subroutine allocates memory for the buffer associated with the field, initializes the len field to zero, and initializes the buf pointer and the maxlen field accordingly. The length of the buffer allocated is based on the same size information returned to the user from the t_open and t_getinfo subroutines. Thus, the fd parameter must refer to the transport end point through which the newly allocated structure will be passed, so that the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2, the t_alloc subroutine will be unable to determine the size of the buffer to allocate; it then fails, setting the t_errno variable to TSYSERR and the errno global variable to EINVAL. For any field not specified in the fields parameter, the buf field is set to null and the maxlen field is set to 0. |
On successful completion, the t_alloc subroutine returns a pointer to the newly allocated structure. Otherwise, it returns a null pointer.
On failure, the t_errno variable is set to one of the following:
Value | Description |
---|---|
TBADF | The specified file descriptor does not refer to a transport end point. |
TNOSTRUCTYPE | Unsupported structure type requested. This can include a request for a structure type which is inconsistent with the transport provider type specified, for example, connection-oriented or connectionless. |
TSYSERR | A system error has occurred during execution of this function. |