8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / krb5 / kadm5 / misc_free.c
blob0a064b68723414d17eb4260f69c855c268c11883
1 /*
2 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 * Openvision retains the copyright to derivative works of
5 * this source code. Do *NOT* create a derivative of this
6 * source code before consulting with your legal department.
7 * Do *NOT* integrate *ANY* of this source code into another
8 * product before consulting with your legal department.
10 * For further information, read the top-level Openvision
11 * copyright which is contained in the top-level MIT Kerberos
12 * copyright.
14 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
20 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
22 * $Header$
25 #if !defined(lint) && !defined(__CODECENTER__)
26 static char *rcsid = "$Header$";
27 #endif
28 #include "server_internal.h"
29 #include <kadm5/admin.h>
30 #include <stdlib.h>
32 kadm5_ret_t
33 kadm5_free_policy_ent(void *server_handle, kadm5_policy_ent_t val)
35 kadm5_server_handle_t handle = server_handle;
37 _KADM5_CHECK_HANDLE(server_handle);
39 if(val) {
40 if (val->policy)
41 free(val->policy);
42 if (handle->api_version == KADM5_API_VERSION_1)
43 free(val);
45 return KADM5_OK;
48 kadm5_ret_t
49 kadm5_free_name_list(void *server_handle, char **names, int count)
51 _KADM5_CHECK_HANDLE(server_handle);
53 while (count--)
54 free(names[count]);
55 free(names);
56 return KADM5_OK;
59 /* XXX this ought to be in libkrb5.a, but isn't */
60 kadm5_ret_t krb5_free_key_data_contents(context, key)
61 krb5_context context;
62 krb5_key_data *key;
64 int i, idx;
66 idx = (key->key_data_ver == 1 ? 1 : 2);
67 for (i = 0; i < idx; i++) {
68 if (key->key_data_contents[i]) {
69 memset(key->key_data_contents[i], 0, key->key_data_length[i]);
70 free(key->key_data_contents[i]);
73 return KADM5_OK;
76 kadm5_ret_t kadm5_free_key_data(void *server_handle,
77 krb5_int16 *n_key_data,
78 krb5_key_data *key_data)
80 kadm5_server_handle_t handle = server_handle;
81 int i, nkeys = (int) *n_key_data;
83 _KADM5_CHECK_HANDLE(server_handle);
85 if (key_data == NULL)
86 return KADM5_OK;
88 for (i = 0; i < nkeys; i++)
89 krb5_free_key_data_contents(handle->context, &key_data[i]);
90 free(key_data);
91 return KADM5_OK;
94 kadm5_ret_t
95 kadm5_free_principal_ent(void *server_handle,
96 kadm5_principal_ent_t val)
98 kadm5_server_handle_t handle = server_handle;
99 int i;
101 _KADM5_CHECK_HANDLE(server_handle);
103 if(val) {
104 if(val->principal)
105 krb5_free_principal(handle->context, val->principal);
106 if(val->mod_name)
107 krb5_free_principal(handle->context, val->mod_name);
108 if(val->policy)
109 free(val->policy);
110 if (handle->api_version > KADM5_API_VERSION_1) {
111 if (val->n_key_data) {
112 for (i = 0; i < val->n_key_data; i++)
113 krb5_free_key_data_contents(handle->context,
114 &val->key_data[i]);
115 free(val->key_data);
117 if (val->tl_data) {
118 krb5_tl_data *tl;
120 while (val->tl_data) {
121 tl = val->tl_data->tl_data_next;
122 free(val->tl_data->tl_data_contents);
123 free(val->tl_data);
124 val->tl_data = tl;
129 if (handle->api_version == KADM5_API_VERSION_1)
130 free(val);
132 return KADM5_OK;