t_free() — Free a library structure

Standards

Standards / Extensions C or C++ Dependencies
XPG4.2 both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>

int t_free(char *ptr, int struct_type);

General description

Frees memory previously allocated by t_alloc(). This function frees memory for the specified structure, and also frees memory for buffers referenced by the structure.

The argument ptr points to one of the seven structure types described for t_alloc() , and struct_type identifies the type of that structure which must be one of the following:
        T_BIND        struct    t_bind
        T_CALL        struct    t_call
        T_OPTMGMT     struct    t_optmgmt
        T_DIS         struct    t_discon
        T_UNITDATA    struct    t_unitdata
        T_UDERROR     struct    t_uderr
        T_INFO        struct    t_info
where each of these structures is used as an argument to one or more transport functions.

t_free() checks the addr, opt and udata fields of the given structure (as appropriate) and frees the buffers pointed to by the buf field of the netbuf structure. If buf is a NULL pointer, t_free() does not attempt to free memory. After all buffers are freed, t_free() frees the memory associated with the structure pointed to by ptr.

Undefined results occur if ptr or any of the buf pointers points to a block of memory that was not previously allocated by t_alloc().

Valid states: All - except for T_UNINIT

Returned value

If successful, t_free() returns 0.

If unsuccessful, t_free() returns -1 and sets errno to one of the following values:
Error Code
Description
TNOSTRUCTYPE
Unsupported struct_type requested.
TPROTO
This error indicates that a communication problem has been detected between XTI and the transport provider for which there is no other suitable XTI (t_errno).
TSYSERR
A system error has occurred during execution of this function.

Related information