t_free.c (7c478bd9) | t_free.c (61961e0f) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ |
22 |
|
22/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23/* All Rights Reserved */ 24 | 23/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 24/* All Rights Reserved */ 25 |
25 | |
26/* | 26/* |
27 * Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved. | 27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
28 * Use is subject to license terms. 29 */ 30 | 28 * Use is subject to license terms. 29 */ 30 |
31 | |
32#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ 33 34#include "mt.h" 35#include <xti.h> 36#include <errno.h> 37#include <stropts.h> 38#include <stdlib.h> 39#include <sys/types.h> | 31#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ 32 33#include "mt.h" 34#include <xti.h> 35#include <errno.h> 36#include <stropts.h> 37#include <stdlib.h> 38#include <sys/types.h> |
40#include <rpc/trace.h> | |
41#include "tx.h" 42 43int 44_tx_free(char *ptr, int struct_type, int api_semantics) 45{ 46 union structptrs { 47 struct t_bind *bind; 48 struct t_call *call; 49 struct t_discon *dis; 50 struct t_optmgmt *opt; 51 struct t_unitdata *udata; 52 struct t_uderr *uderr; 53 } p; 54 55 /* 56 * Free all the buffers associated with the appropriate 57 * fields of each structure. 58 */ 59 | 39#include "tx.h" 40 41int 42_tx_free(char *ptr, int struct_type, int api_semantics) 43{ 44 union structptrs { 45 struct t_bind *bind; 46 struct t_call *call; 47 struct t_discon *dis; 48 struct t_optmgmt *opt; 49 struct t_unitdata *udata; 50 struct t_uderr *uderr; 51 } p; 52 53 /* 54 * Free all the buffers associated with the appropriate 55 * fields of each structure. 56 */ 57 |
60 trace2(TR_t_free, 0, struct_type); | |
61 switch (struct_type) { 62 63 case T_BIND: | 58 switch (struct_type) { 59 60 case T_BIND: |
61 /* LINTED pointer cast */ |
|
64 p.bind = (struct t_bind *)ptr; 65 if (p.bind->addr.buf != NULL) 66 free(p.bind->addr.buf); 67 break; 68 69 case T_CALL: | 62 p.bind = (struct t_bind *)ptr; 63 if (p.bind->addr.buf != NULL) 64 free(p.bind->addr.buf); 65 break; 66 67 case T_CALL: |
68 /* LINTED pointer cast */ |
|
70 p.call = (struct t_call *)ptr; 71 if (p.call->addr.buf != NULL) 72 free(p.call->addr.buf); 73 if (p.call->opt.buf != NULL) 74 free(p.call->opt.buf); 75 if (p.call->udata.buf != NULL) 76 free(p.call->udata.buf); 77 break; 78 79 case T_OPTMGMT: | 69 p.call = (struct t_call *)ptr; 70 if (p.call->addr.buf != NULL) 71 free(p.call->addr.buf); 72 if (p.call->opt.buf != NULL) 73 free(p.call->opt.buf); 74 if (p.call->udata.buf != NULL) 75 free(p.call->udata.buf); 76 break; 77 78 case T_OPTMGMT: |
79 /* LINTED pointer cast */ |
|
80 p.opt = (struct t_optmgmt *)ptr; 81 if (p.opt->opt.buf != NULL) 82 free(p.opt->opt.buf); 83 break; 84 85 case T_DIS: | 80 p.opt = (struct t_optmgmt *)ptr; 81 if (p.opt->opt.buf != NULL) 82 free(p.opt->opt.buf); 83 break; 84 85 case T_DIS: |
86 /* LINTED pointer cast */ |
|
86 p.dis = (struct t_discon *)ptr; 87 if (p.dis->udata.buf != NULL) 88 free(p.dis->udata.buf); 89 break; 90 91 case T_UNITDATA: | 87 p.dis = (struct t_discon *)ptr; 88 if (p.dis->udata.buf != NULL) 89 free(p.dis->udata.buf); 90 break; 91 92 case T_UNITDATA: |
93 /* LINTED pointer cast */ |
|
92 p.udata = (struct t_unitdata *)ptr; 93 if (p.udata->addr.buf != NULL) 94 free(p.udata->addr.buf); 95 if (p.udata->opt.buf != NULL) 96 free(p.udata->opt.buf); 97 if (p.udata->udata.buf != NULL) 98 free(p.udata->udata.buf); 99 break; 100 101 case T_UDERROR: | 94 p.udata = (struct t_unitdata *)ptr; 95 if (p.udata->addr.buf != NULL) 96 free(p.udata->addr.buf); 97 if (p.udata->opt.buf != NULL) 98 free(p.udata->opt.buf); 99 if (p.udata->udata.buf != NULL) 100 free(p.udata->udata.buf); 101 break; 102 103 case T_UDERROR: |
104 /* LINTED pointer cast */ |
|
102 p.uderr = (struct t_uderr *)ptr; 103 if (p.uderr->addr.buf != NULL) 104 free(p.uderr->addr.buf); 105 if (p.uderr->opt.buf != NULL) 106 free(p.uderr->opt.buf); 107 break; 108 109 case T_INFO: 110 break; 111 112 default: 113 if (_T_IS_XTI(api_semantics)) { 114 t_errno = TNOSTRUCTYPE; | 105 p.uderr = (struct t_uderr *)ptr; 106 if (p.uderr->addr.buf != NULL) 107 free(p.uderr->addr.buf); 108 if (p.uderr->opt.buf != NULL) 109 free(p.uderr->opt.buf); 110 break; 111 112 case T_INFO: 113 break; 114 115 default: 116 if (_T_IS_XTI(api_semantics)) { 117 t_errno = TNOSTRUCTYPE; |
115 trace2(TR_t_free, 1, struct_type); | |
116 } else { /* TX_TLI_API */ 117 t_errno = TSYSERR; | 118 } else { /* TX_TLI_API */ 119 t_errno = TSYSERR; |
118 trace2(TR_t_free, 1, struct_type); | |
119 errno = EINVAL; 120 } 121 return (-1); 122 } 123 124 free(ptr); | 120 errno = EINVAL; 121 } 122 return (-1); 123 } 124 125 free(ptr); |
125 trace2(TR_t_free, 1, struct_type); | |
126 return (0); 127} | 126 return (0); 127} |