Add empty file to prevent the version from libm-ieee754 be compiled
[glibc/history.git] / nis / nis_free.c
bloba4ab7378e6ac324fa65a347575ad3cd137557358
1 /* Copyright (c) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nislib.h>
23 void
24 nis_free_attr (nis_attr *obj)
26 if (obj == NULL)
27 return;
29 if (obj->zattr_ndx)
31 free (obj->zattr_ndx);
32 obj->zattr_ndx = NULL;
35 if (obj->zattr_val.zattr_val_val)
37 free (obj->zattr_val.zattr_val_val);
38 obj->zattr_val.zattr_val_val = NULL;
39 obj->zattr_val.zattr_val_len = 0;
43 void
44 nis_free_request (ib_request *ibreq)
46 unsigned int i;
48 for (i = 0; i < ibreq->ibr_srch.ibr_srch_len; ++i)
50 nis_free_attr (&(ibreq->ibr_srch.ibr_srch_val)[i]);
51 ibreq->ibr_srch.ibr_srch_val = NULL;
52 ibreq->ibr_srch.ibr_srch_len = 0;
55 if (ibreq->ibr_name)
57 free (ibreq->ibr_name);
58 ibreq->ibr_name = NULL;
61 if (ibreq->ibr_cookie.n_bytes)
63 free (ibreq->ibr_cookie.n_bytes);
64 ibreq->ibr_cookie.n_bytes = NULL;
65 ibreq->ibr_cookie.n_len = 0;
69 void
70 nis_free_endpoints (endpoint *ep, unsigned int len)
72 unsigned int i;
74 if (ep == NULL)
75 return;
77 for (i = 0; i < len; ++i)
79 if (ep[i].uaddr)
81 free (ep[i].uaddr);
82 ep[i].uaddr = NULL;
84 if (ep[i].family)
86 free (ep[i].family);
87 ep[i].family = NULL;
89 if (ep[i].proto)
91 free (ep[i].proto);
92 ep[i].proto = NULL;
97 void
98 nis_free_servers (nis_server *obj, unsigned int len)
100 unsigned int i;
102 if (obj == NULL)
103 return;
105 for (i = 0; i < len; i++)
107 if (obj[i].name)
109 free (obj[i].name);
110 obj[i].name = NULL;
112 if (obj[i].ep.ep_len > 0)
114 nis_free_endpoints (obj[i].ep.ep_val, obj[i].ep.ep_len);
115 free (obj[i].ep.ep_val);
116 obj[i].ep.ep_val = NULL;
117 obj[i].ep.ep_len = 0;
119 if (obj[i].pkey.n_bytes && obj[i].pkey.n_len > 0)
121 free (obj[i].pkey.n_bytes);
122 obj[i].pkey.n_bytes = NULL;
123 obj[i].pkey.n_len = 0;
128 void
129 nis_free_directory (directory_obj *obj)
131 if (obj == NULL)
132 return;
133 if (obj->do_name)
135 free (obj->do_name);
136 obj->do_name = NULL;
138 if (obj->do_servers.do_servers_len > 0)
140 nis_free_servers (obj->do_servers.do_servers_val,
141 obj->do_servers.do_servers_len);
142 free (obj->do_servers.do_servers_val);
143 obj->do_servers.do_servers_val = NULL;
144 obj->do_servers.do_servers_len = 0;
146 if (obj->do_armask.do_armask_len > 0)
148 free (obj->do_armask.do_armask_val);
149 obj->do_armask.do_armask_val = NULL;
150 obj->do_armask.do_armask_len = 0;
154 void
155 nis_free_group (group_obj *obj)
157 unsigned int i;
159 if (obj->gr_members.gr_members_len > 0)
161 for (i = 0; i < obj->gr_members.gr_members_len; ++i)
162 if (obj->gr_members.gr_members_val[i])
163 free (obj->gr_members.gr_members_val[i]);
164 free (obj->gr_members.gr_members_val);
165 obj->gr_members.gr_members_val = NULL;
166 obj->gr_members.gr_members_len = 0;
170 void
171 nis_free_table (table_obj *obj)
173 if (obj == NULL)
174 return;
176 if (obj->ta_type)
178 free (obj->ta_type);
179 obj->ta_type = NULL;
182 if (obj->ta_cols.ta_cols_val)
184 unsigned int i;
186 for (i = 0; i < obj->ta_cols.ta_cols_len; ++i)
187 if (obj->ta_cols.ta_cols_val[i].tc_name)
188 free (obj->ta_cols.ta_cols_val[i].tc_name);
189 free (obj->ta_cols.ta_cols_val);
190 obj->ta_cols.ta_cols_val = NULL;
191 obj->ta_cols.ta_cols_len = 0;
194 if (obj->ta_path)
196 free (obj->ta_path);
197 obj->ta_path = NULL;
201 void
202 nis_free_entry (entry_obj *obj)
204 if (obj == NULL)
205 return;
207 if (obj->en_type)
209 free (obj->en_type);
210 obj->en_type = 0;
213 if (obj->en_cols.en_cols_val)
215 unsigned int i;
217 for (i = 0; i < obj->en_cols.en_cols_len; ++i)
218 if (obj->en_cols.en_cols_val[i].ec_value.ec_value_val)
219 free (obj->en_cols.en_cols_val[i].ec_value.ec_value_val);
220 free (obj->en_cols.en_cols_val);
221 obj->en_cols.en_cols_val = NULL;
222 obj->en_cols.en_cols_len = 0;
226 void
227 nis_free_link (link_obj *obj)
229 if (obj == NULL)
230 return;
232 if (obj->li_attrs.li_attrs_val)
234 unsigned int i;
236 for (i = 0; i < obj->li_attrs.li_attrs_len; ++i)
238 if (obj->li_attrs.li_attrs_val[i].zattr_ndx)
239 free (obj->li_attrs.li_attrs_val[i].zattr_ndx);
240 if (obj->li_attrs.li_attrs_val[i].zattr_val.zattr_val_val)
241 free (obj->li_attrs.li_attrs_val[i].zattr_val.zattr_val_val);
243 free (obj->li_attrs.li_attrs_val);
244 obj->li_attrs.li_attrs_val = NULL;
245 obj->li_attrs.li_attrs_len = 0;
248 if (obj->li_name)
250 free (obj->li_name);
251 obj->li_name = NULL;
255 void
256 nis_free_object (nis_object *obj)
259 if (obj == NULL)
260 return;
262 if (obj->zo_name)
264 free (obj->zo_name);
265 obj->zo_name = NULL;
267 if (obj->zo_owner)
269 free (obj->zo_owner);
270 obj->zo_owner = NULL;
272 if (obj->zo_group)
274 free (obj->zo_group);
275 obj->zo_group = NULL;
277 if (obj->zo_domain)
279 free (obj->zo_domain);
280 obj->zo_domain = NULL;
282 switch (obj->zo_data.zo_type)
284 case BOGUS_OBJ:
285 break;
286 case NO_OBJ:
287 break;
288 case DIRECTORY_OBJ:
289 nis_free_directory (&obj->zo_data.objdata_u.di_data);
290 break;
291 case GROUP_OBJ:
292 nis_free_group (&obj->zo_data.objdata_u.gr_data);
293 break;
294 case TABLE_OBJ:
295 nis_free_table (&obj->zo_data.objdata_u.ta_data);
296 break;
297 case ENTRY_OBJ:
298 nis_free_entry (&obj->zo_data.objdata_u.en_data);
299 break;
300 case LINK_OBJ:
301 nis_free_link (&obj->zo_data.objdata_u.li_data);
302 break;
303 case PRIVATE_OBJ:
304 if (obj->zo_data.objdata_u.po_data.po_data_val)
306 free (obj->zo_data.objdata_u.po_data.po_data_val);
307 obj->zo_data.objdata_u.po_data.po_data_val = NULL;
309 break;
310 default:
311 break;
313 obj->zo_data.zo_type = NO_OBJ;
316 void
317 nis_freeresult (nis_result *res)
319 unsigned int i;
321 if (res == NULL)
322 return;
324 for (i = 0; i < res->objects.objects_len; i++)
325 nis_free_object (&(res->objects.objects_val)[i]);
327 if (res->objects.objects_val != NULL)
328 free (res->objects.objects_val);
330 if (res->cookie.n_bytes != NULL && res->cookie.n_len > 0)
331 free (res->cookie.n_bytes);
333 free (res);