Deleted Added
full compact
iidesc.c (178529) iidesc.c (178546)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 54 unchanged lines hidden (view full) ---

63
64 if (ii->ii_name)
65 return (hash_name(nbuckets, ii->ii_name));
66
67 return (h);
68}
69
70static int
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 54 unchanged lines hidden (view full) ---

63
64 if (ii->ii_name)
65 return (hash_name(nbuckets, ii->ii_name));
66
67 return (h);
68}
69
70static int
71iidesc_cmp(iidesc_t *src, iidesc_find_t *find)
71iidesc_cmp(void *arg1, void *arg2)
72{
72{
73 iidesc_t *src = arg1;
74 iidesc_find_t *find = arg2;
73 iidesc_t *tgt = find->iif_tgt;
74
75 if (src->ii_type != tgt->ii_type ||
76 !streq(src->ii_name, tgt->ii_name))
77 return (0);
78
79 find->iif_ret = src;
80
81 return (-1);
82}
83
84void
85iidesc_add(hash_t *hash, iidesc_t *new)
86{
87 iidesc_find_t find;
88
89 find.iif_tgt = new;
90 find.iif_ret = NULL;
91
75 iidesc_t *tgt = find->iif_tgt;
76
77 if (src->ii_type != tgt->ii_type ||
78 !streq(src->ii_name, tgt->ii_name))
79 return (0);
80
81 find->iif_ret = src;
82
83 return (-1);
84}
85
86void
87iidesc_add(hash_t *hash, iidesc_t *new)
88{
89 iidesc_find_t find;
90
91 find.iif_tgt = new;
92 find.iif_ret = NULL;
93
92 (void) hash_match(hash, new, (int (*)())iidesc_cmp, &find);
94 (void) hash_match(hash, new, iidesc_cmp, &find);
93
94 if (find.iif_ret != NULL) {
95 iidesc_t *old = find.iif_ret;
96 iidesc_t tmp;
97 /* replacing existing one */
98 bcopy(old, &tmp, sizeof (tmp));
99 bcopy(new, old, sizeof (*old));
100 bcopy(&tmp, new, sizeof (*new));
101
102 iidesc_free(new, NULL);
103 return;
104 }
105
106 hash_add(hash, new);
107}
108
109void
95
96 if (find.iif_ret != NULL) {
97 iidesc_t *old = find.iif_ret;
98 iidesc_t tmp;
99 /* replacing existing one */
100 bcopy(old, &tmp, sizeof (tmp));
101 bcopy(new, old, sizeof (*old));
102 bcopy(&tmp, new, sizeof (*new));
103
104 iidesc_free(new, NULL);
105 return;
106 }
107
108 hash_add(hash, new);
109}
110
111void
110iter_iidescs_by_name(tdata_t *td, const char *name,
111 int (*func)(iidesc_t *, void *), void *data)
112iter_iidescs_by_name(tdata_t *td, char const *name,
113 int (*func)(void *, void *), void *data)
112{
113 iidesc_t tmpdesc;
114{
115 iidesc_t tmpdesc;
114 bzero(&tmpdesc, sizeof (iidesc_t));
115 tmpdesc.ii_name = (char *)name;
116 (void) hash_match(td->td_iihash, &tmpdesc, (int (*)())func, data);
116 bzero(&tmpdesc, sizeof(tmpdesc));
117 tmpdesc.ii_name = xstrdup(name);
118 (void) hash_match(td->td_iihash, &tmpdesc, func, data);
119 free(tmpdesc.ii_name);
117}
118
119iidesc_t *
120iidesc_dup(iidesc_t *src)
121{
122 iidesc_t *tgt;
123
124 tgt = xmalloc(sizeof (iidesc_t));

--- 21 unchanged lines hidden (view full) ---

146 tgt->ii_name = name ? xstrdup(name) : NULL;
147 tgt->ii_owner = owner ? xstrdup(owner) : NULL;
148
149 return (tgt);
150}
151
152/*ARGSUSED*/
153void
120}
121
122iidesc_t *
123iidesc_dup(iidesc_t *src)
124{
125 iidesc_t *tgt;
126
127 tgt = xmalloc(sizeof (iidesc_t));

--- 21 unchanged lines hidden (view full) ---

149 tgt->ii_name = name ? xstrdup(name) : NULL;
150 tgt->ii_owner = owner ? xstrdup(owner) : NULL;
151
152 return (tgt);
153}
154
155/*ARGSUSED*/
156void
154iidesc_free(iidesc_t *idp, void *private)
157iidesc_free(void *arg, void *private __unused)
155{
158{
159 iidesc_t *idp = arg;
156 if (idp->ii_name)
157 free(idp->ii_name);
158 if (idp->ii_nargs)
159 free(idp->ii_args);
160 if (idp->ii_owner)
161 free(idp->ii_owner);
162 free(idp);
163}

--- 30 unchanged lines hidden ---
160 if (idp->ii_name)
161 free(idp->ii_name);
162 if (idp->ii_nargs)
163 free(idp->ii_args);
164 if (idp->ii_owner)
165 free(idp->ii_owner);
166 free(idp);
167}

--- 30 unchanged lines hidden ---