t_free Subroutine for Transport Layer Interface

Purpose

Frees a library structure.

Library

Transport Layer Interface Library (libtli.a)

Syntax

#include <tiuser.h>

int t_free(ptr, struct_type)
char * ptr;
int  struct_type;

Description

The t_free subroutine frees memory previously allocated by the t_alloc subroutine. This subroutine frees memory for the specified structure and also frees memory for buffers referenced by the structure.

The t_free subroutine 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 the buf field is null, the t_free subroutine does not attempt to free memory. After all buffers are freed, the t_free subroutine frees the memory associated with the structure pointed to by the ptr parameter.

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

Parameters

Item Description
ptr Points to one of the seven structure types described for the t_alloc subroutine.
struct_type Identifies the type of that structure. The type can be one of the following:
Type
Structure
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

Each of these structure types is used as a parameter to one or more transport subroutines.

Return Values

On successful completion, the t_free subroutine returns a value of 0. Otherwise, it returns a value of -1, and the t_errno variable is set to indicate the error.

Error Codes

If unsuccessful, the t_errno variable is set to the following:

Value Description
TNOSTRUCTYPE Unsupported structure type requested.
TSYSERR A system error has occurred during execution of this function.