t_alloc(S) (TLI/XTI) 6 January 1993 t_alloc(S) Name t_alloc - allocate a library structure Syntax TLI syntax cc . . . -lnsls #include <sys/tiuser.h> char * t_alloc (fd, struct_type, fields) int fd, struct_type, fields; XTI syntax cc . . . -lxti #include <xti.h> char * t_alloc (fd, struct_type, fields) int fd, struct_type, fields; Description The talloc function dynamically allocates memory for the various trans- port function argument structures as specified below. This function allocates memory for the specified structure, and also allocates memory for buffers referenced by the structure. The structure to allocate is specified by structtype, and can be one of the following: TLI structtype XTI structtype Allocated Value Value Structure ___________________________________________________________________ TBIND TBINDSTR struct t_bind TCALL TCALLSTR struct t_call TDIS TDISSTR struct t_discon TINFO TINFOSTR struct t_info TOPTMGMT TOPTMGMTSTR struct t_optmgmt TUDERROR TUDERRORSTR struct t_uderr TUNITDATA TUNITDATASTR struct t_unitdata Each of these structures may subsequently be used as an argument to one or more transport functions. Each of the previously listed structures, except TINFO (TLI) or TINFOSTR (XTI), contains at least one field of type struct netbuf. netbuf is described in netbuf(FP). For each field of this type, the user may specify that the buffer for that field should be allocated as well. The fields argument specifies this option, where the argument is the bitwise-OR of any of the following: TALL All relevant fields of the given structure. TADDR The addr field of the tbind, tcall, tunitdata, or tuderr structures. TOPT The opt field of the toptmgmt, tcall, tunitdata, or tuderr structures. TUDATA The udata field of the tcall, tdiscon, or tunitdata struc- tures. For each field specified in fields, talloc allocates memory for the buffer associated with the field, and initialize the buf pointer and max- len (see netbuf in netbuf(FP) for a description of the buf and maxlen) fields accordingly. The length of the buffer allocated is based on the same size information that is returned to the user on topen and tgetinfo. Thus, fd must refer to the transport endpoint through which the newly allocated structure is passed, so that the appropriate size in- formation can be accessed. If the size value associated with any speci- fied field is -1 or -2 (see topen or tgetinfo), talloc is unable to determine the size of the buffer to allocate and fails, setting terrno to TSYSERR and errno to EINVAL. For any field not specified in fields, buf is set to NULL and maxlen is set to zero. Use of talloc to allocate structures helps ensure the compatibility of user programs with future releases of the transport interface. On failure, terrno may be set to one of the following: [TBADF] The specified file descriptor does not refer to a transport endpoint. [TNOSTRUCTYPE] For XTI, an incorrect value was specified in the structtype argument. [TSYSERR] A system error has occurred during execution of this function. The following conditions accompany this error: terrno Value errno Value Cause _____________________________________________________ TSYSERR not set Device or system failure TSYSERR EINVAL structtype out of range, or internal error TSYSERR ENOMEM Memory could not be allocated for specified structtype request See also netbuf(FP), tfree(S), tgetinfo(S), topen(S), tinfo(FP) Diagnostics On successful completion, talloc returns a pointer to the newly allo- cated structure. On failure, NULL is returned. Standards conformance talloc is conformant with: AT&T SVID Issue 2; X/Open Portability Guide, Issue 3, 1989; and Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2).