Date: Thu, 16 Aug 2007 19:39:56 GMT From: Fredrik Lindberg <fli@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125232 for review Message-ID: <200708161939.l7GJduet010714@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125232 Change 125232 by fli@fli_nexus on 2007/08/16 19:39:02 - Pass shared-flag to dbr_ident_add() on shared resources. - Free memory allocated during parse. Affected files ... .. //depot/projects/soc2007/fli-mdns_sd/mdnsd/parse.y#4 edit Differences ... ==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/parse.y#4 (text+ko) ==== @@ -220,10 +220,10 @@ cfg_rrset.cr_ident = $2; } rrset_content EBRACE { - struct cfg_name *cn; - struct cfg_res *cs; - struct cfg_resdata *csd; - int ttl; + struct cfg_name *cn, *cn2; + struct cfg_res *cs, *cs2; + struct cfg_resdata *csd, *csd2; + int flags, ttl; wchar_t *nam, *wp; size_t len; @@ -240,23 +240,30 @@ cfg_rrset.cr_ident, (cfg_rrset.cr_shared ? " (shared)" : ""), cfg_rrset.cr_namcount); - dbr_ident_add(dbr, cfg_rrset.cr_ident); - TAILQ_FOREACH(cn, &cfg_rrset.cr_names, cn_next) { + flags = 0; + if (cfg_rrset.cr_shared) + flags |= DBI_SHARED; + + dbr_ident_add(dbr, cfg_rrset.cr_ident, flags); + TAILQ_FOREACH_SAFE(cn, &cfg_rrset.cr_names, cn_next, cn2) { dprintf(DEBUG_CFGPARSE, " %s", cn->cn_name); len = strlen(cn->cn_name) + 1; nam = malloc(len * sizeof(wchar_t)); mbstowcs(nam, cn->cn_name, len); dbr_name_add(dbr, cfg_rrset.cr_ident, nam); free(nam); + + TAILQ_REMOVE(&cfg_rrset.cr_names, cn, cn_next); + free(cn); } dprintf(DEBUG_CFGPARSE, "rrset resources"); - TAILQ_FOREACH(cs, &cfg_rrset.cr_res, cs_next) { + TAILQ_FOREACH_SAFE(cs, &cfg_rrset.cr_res, cs_next, cs2) { dprintf(DEBUG_CFGPARSE, " type %d", cs->cs_type); ttl = cs->cs_ttl > 0 ? cs->cs_ttl : (cfg_rrset.cr_ttl > 0 ? cfg_rrset.cr_ttl : (cfg_rrset.cr_shared ? cfg_ttl_shared : cfg_ttl)); - TAILQ_FOREACH(csd, &cs->cs_data, csd_next) { + TAILQ_FOREACH_SAFE(csd, &cs->cs_data, csd_next, csd2) { dprintf(DEBUG_CFGPARSE, " data = %s, ttl = %d", csd->csd_data, ttl); @@ -272,10 +279,19 @@ dbr_res_add(dbr, cfg_rrset.cr_ident, mdns_c_in, cs->cs_type, ttl, wp, 0); + + free(wp); } + TAILQ_REMOVE(&cs->cs_data, csd, csd_next); + free(csd); } + + TAILQ_REMOVE(&cfg_rrset.cr_res, cs, cs_next); + free(cs); } + free(cfg_rrset.cr_ident); + dprintf(DEBUG_CFGPARSE, "end of rrset statement"); } ;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708161939.l7GJduet010714>