Print this page
patch tsoome-feedback


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 #include <libxml/parser.h>
  30 #include <fm/libtopo.h>
  31 #include <topo_alloc.h>
  32 #include <topo_error.h>
  33 #include <topo_parse.h>
  34 #include <topo_subr.h>
  35 
  36 tf_info_t *
  37 tf_info_new(topo_mod_t *mp, xmlDocPtr doc, xmlChar *scheme)
  38 {
  39         tf_info_t *r;
  40 
  41         if ((r = topo_mod_zalloc(mp, sizeof (tf_info_t))) == NULL)
  42                 return (NULL);
  43         r->tf_flags = TF_LIVE;
  44         if ((r->tf_scheme = topo_mod_strdup(mp, (char *)scheme)) == NULL) {
  45                 tf_info_free(mp, r);
  46                 return (NULL);
  47         }
  48         r->tf_xdoc = doc;


 178 {
 179         tf_pad_t *r;
 180 
 181         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "new pad p=%d, d=%d\n",
 182             pcnt, dcnt);
 183         if ((r = topo_mod_zalloc(mp, sizeof (tf_pad_t))) == NULL)
 184                 return (NULL);
 185         r->tpad_pgcnt = pcnt;
 186         r->tpad_dcnt = dcnt;
 187         return (r);
 188 }
 189 
 190 void
 191 tf_pad_free(topo_mod_t *mp, tf_pad_t *p)
 192 {
 193         int n;
 194         if (p == NULL)
 195                 return;
 196         if (p->tpad_pgs != NULL) {
 197                 for (n = 0; n < p->tpad_pgcnt; n++)
 198                         if (p->tpad_pgs[n] != NULL)
 199                                 nvlist_free(p->tpad_pgs[n]);
 200                 topo_mod_free(mp,
 201                     p->tpad_pgs, p->tpad_pgcnt * sizeof (nvlist_t *));
 202         }
 203         tf_rdata_free(mp, p->tpad_child);
 204         tf_rdata_free(mp, p->tpad_sibs);
 205         topo_mod_free(mp, p, sizeof (tf_pad_t));
 206 }
 207 
 208 void
 209 tf_edata_free(topo_mod_t *mp, tf_edata_t *p)
 210 {
 211         if (p == NULL)
 212                 return;
 213         if (p->te_name != NULL)
 214                 xmlFree(p->te_name);
 215         topo_mod_free(mp, p, sizeof (tf_edata_t));
 216 }


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 


  27 #include <libxml/parser.h>
  28 #include <fm/libtopo.h>
  29 #include <topo_alloc.h>
  30 #include <topo_error.h>
  31 #include <topo_parse.h>
  32 #include <topo_subr.h>
  33 
  34 tf_info_t *
  35 tf_info_new(topo_mod_t *mp, xmlDocPtr doc, xmlChar *scheme)
  36 {
  37         tf_info_t *r;
  38 
  39         if ((r = topo_mod_zalloc(mp, sizeof (tf_info_t))) == NULL)
  40                 return (NULL);
  41         r->tf_flags = TF_LIVE;
  42         if ((r->tf_scheme = topo_mod_strdup(mp, (char *)scheme)) == NULL) {
  43                 tf_info_free(mp, r);
  44                 return (NULL);
  45         }
  46         r->tf_xdoc = doc;


 176 {
 177         tf_pad_t *r;
 178 
 179         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "new pad p=%d, d=%d\n",
 180             pcnt, dcnt);
 181         if ((r = topo_mod_zalloc(mp, sizeof (tf_pad_t))) == NULL)
 182                 return (NULL);
 183         r->tpad_pgcnt = pcnt;
 184         r->tpad_dcnt = dcnt;
 185         return (r);
 186 }
 187 
 188 void
 189 tf_pad_free(topo_mod_t *mp, tf_pad_t *p)
 190 {
 191         int n;
 192         if (p == NULL)
 193                 return;
 194         if (p->tpad_pgs != NULL) {
 195                 for (n = 0; n < p->tpad_pgcnt; n++)

 196                         nvlist_free(p->tpad_pgs[n]);
 197                 topo_mod_free(mp,
 198                     p->tpad_pgs, p->tpad_pgcnt * sizeof (nvlist_t *));
 199         }
 200         tf_rdata_free(mp, p->tpad_child);
 201         tf_rdata_free(mp, p->tpad_sibs);
 202         topo_mod_free(mp, p, sizeof (tf_pad_t));
 203 }
 204 
 205 void
 206 tf_edata_free(topo_mod_t *mp, tf_edata_t *p)
 207 {
 208         if (p == NULL)
 209                 return;
 210         if (p->te_name != NULL)
 211                 xmlFree(p->te_name);
 212         topo_mod_free(mp, p, sizeof (tf_edata_t));
 213 }