2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1988, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A#include "mt.h"
2N/A#include <xti.h>
2N/A#include <errno.h>
2N/A#include <stropts.h>
2N/A#include <stdlib.h>
2N/A#include <sys/types.h>
2N/A#include "tx.h"
2N/A
2N/Aint
2N/A_tx_free(void *ptr, int struct_type, int api_semantics)
2N/A{
2N/A union structptrs {
2N/A struct t_bind *bind;
2N/A struct t_call *call;
2N/A struct t_discon *dis;
2N/A struct t_optmgmt *opt;
2N/A struct t_unitdata *udata;
2N/A struct t_uderr *uderr;
2N/A } p;
2N/A
2N/A /*
2N/A * Free all the buffers associated with the appropriate
2N/A * fields of each structure.
2N/A */
2N/A
2N/A switch (struct_type) {
2N/A
2N/A case T_BIND:
2N/A p.bind = (struct t_bind *)ptr;
2N/A if (p.bind->addr.buf != NULL)
2N/A free(p.bind->addr.buf);
2N/A break;
2N/A
2N/A case T_CALL:
2N/A p.call = (struct t_call *)ptr;
2N/A if (p.call->addr.buf != NULL)
2N/A free(p.call->addr.buf);
2N/A if (p.call->opt.buf != NULL)
2N/A free(p.call->opt.buf);
2N/A if (p.call->udata.buf != NULL)
2N/A free(p.call->udata.buf);
2N/A break;
2N/A
2N/A case T_OPTMGMT:
2N/A p.opt = (struct t_optmgmt *)ptr;
2N/A if (p.opt->opt.buf != NULL)
2N/A free(p.opt->opt.buf);
2N/A break;
2N/A
2N/A case T_DIS:
2N/A p.dis = (struct t_discon *)ptr;
2N/A if (p.dis->udata.buf != NULL)
2N/A free(p.dis->udata.buf);
2N/A break;
2N/A
2N/A case T_UNITDATA:
2N/A p.udata = (struct t_unitdata *)ptr;
2N/A if (p.udata->addr.buf != NULL)
2N/A free(p.udata->addr.buf);
2N/A if (p.udata->opt.buf != NULL)
2N/A free(p.udata->opt.buf);
2N/A if (p.udata->udata.buf != NULL)
2N/A free(p.udata->udata.buf);
2N/A break;
2N/A
2N/A case T_UDERROR:
2N/A p.uderr = (struct t_uderr *)ptr;
2N/A if (p.uderr->addr.buf != NULL)
2N/A free(p.uderr->addr.buf);
2N/A if (p.uderr->opt.buf != NULL)
2N/A free(p.uderr->opt.buf);
2N/A break;
2N/A
2N/A case T_INFO:
2N/A break;
2N/A
2N/A default:
2N/A if (_T_IS_XTI(api_semantics)) {
2N/A t_errno = TNOSTRUCTYPE;
2N/A } else { /* TX_TLI_API */
2N/A t_errno = TSYSERR;
2N/A errno = EINVAL;
2N/A }
2N/A return (-1);
2N/A }
2N/A
2N/A free(ptr);
2N/A return (0);
2N/A}