Ack with minor comment: su_iter and sg_iter are not great names, perhaps su_node_name & sg_node_name is better?
Any plans for the TODOs? Thanks, HansF On 10 January 2014 16:49, Hans Nordeback <[email protected]> wrote: > osaf/services/saf/amf/amfd/include/node.h | 5 ++- > osaf/services/saf/amf/amfd/nodegroup.cc | 12 ++-------- > osaf/services/saf/amf/amfd/su.cc | 32 > ++++++++++++++---------------- > 3 files changed, 21 insertions(+), 28 deletions(-) > > > diff --git a/osaf/services/saf/amf/amfd/include/node.h > b/osaf/services/saf/amf/amfd/include/node.h > --- a/osaf/services/saf/amf/amfd/include/node.h > +++ b/osaf/services/saf/amf/amfd/include/node.h > @@ -34,7 +34,7 @@ > #ifndef AVD_AVND_H > #define AVD_AVND_H > > -#include <stdbool.h> > +#include <vector> > #include <saAmf.h> > #include <saImm.h> > #include <ncspatricia.h> > @@ -148,8 +148,9 @@ typedef struct avd_ng_tag { > > NCS_PATRICIA_NODE tree_node; /* key will be AMF node group name */ > SaNameT ng_name; > + // TODO HANO number_nodes is redundant, use saAmfNGNodeList.size() > instead > uint32_t number_nodes; /* number of element in saAmfNGNodeList */ > - SaNameT *saAmfNGNodeList; /* array of node names in group */ > + std::vector<SaNameT> saAmfNGNodeList; /* vector of node names in > group */ > > struct avd_ng_tag *cluster_list_ng_next; > struct avd_cluster_tag *ng_on_cluster; > diff --git a/osaf/services/saf/amf/amfd/nodegroup.cc > b/osaf/services/saf/amf/amfd/nodegroup.cc > --- a/osaf/services/saf/amf/amfd/nodegroup.cc > +++ b/osaf/services/saf/amf/amfd/nodegroup.cc > @@ -146,7 +146,7 @@ static AVD_AMF_NG *ng_create(SaNameT *dn > &values_number) == SA_AIS_OK) && (values_number > 0)) { > > ng->number_nodes = values_number; > - ng->saAmfNGNodeList = > static_cast<SaNameT*>(malloc(values_number * sizeof(SaNameT))); > + ng->saAmfNGNodeList.resize(values_number); > for (i = 0; i < values_number; i++) { > if ((node_name = immutil_getNameAttr(attributes, > "saAmfNGNodeList", i)) != NULL) > ng->saAmfNGNodeList[i] = *node_name; > @@ -178,7 +178,7 @@ static void ng_delete(AVD_AMF_NG *ng) > osafassert(rc == NCSCC_RC_SUCCESS); > > osafassert(ng); > - free(ng->saAmfNGNodeList); > + > delete ng; > } > > @@ -481,13 +481,7 @@ static void ng_ccb_apply_modify_hdlr(Ccb > while ((mod = opdata->param.modify.attrMods[i++]) != NULL) { > switch (mod->modType) { > case SA_IMM_ATTR_VALUES_ADD: { > - ng->saAmfNGNodeList = > static_cast<SaNameT*>(realloc(ng->saAmfNGNodeList, > - > (ng->number_nodes + mod->modAttr.attrValuesNumber) * sizeof(SaNameT))); > - > - if (ng->saAmfNGNodeList == NULL) { > - LOG_EM("%s: realloc FAILED", __FUNCTION__); > - exit(1); > - } > + ng->saAmfNGNodeList.resize(ng->number_nodes + > mod->modAttr.attrValuesNumber); > > for (j = 0; j < mod->modAttr.attrValuesNumber; j++) { > ng->saAmfNGNodeList[ng->number_nodes + j] = > *((SaNameT *)mod->modAttr.attrValues[j]); > diff --git a/osaf/services/saf/amf/amfd/su.cc > b/osaf/services/saf/amf/amfd/su.cc > --- a/osaf/services/saf/amf/amfd/su.cc > +++ b/osaf/services/saf/amf/amfd/su.cc > @@ -31,6 +31,13 @@ > > static NCS_PATRICIA_TREE su_db; > > +// TODO HANO place this function in some other file > +bool operator== (SaNameT &lhs, SaNameT &rhs) > +{ > + osafassert((lhs.length <= SA_MAX_NAME_LENGTH) && (rhs.length <= > SA_MAX_NAME_LENGTH)); > + return (!memcmp(&lhs, &rhs, lhs.length)); > +} > + > void avd_su_db_add(AVD_SU *su) > { > unsigned int rc; > @@ -371,9 +378,6 @@ static int is_config_valid(const SaNameT > if ((strstr((char *)saAmfSUHostNodeOrNodeGroup.value, > "safAmfNodeGroup=") != NULL) && > (strstr((char *)saAmfSGSuHostNodeGroup.value, "safAmfNodeGroup=") > != NULL)) { > AVD_AMF_NG *ng_of_su, *ng_of_sg; > - SaNameT *ng_node_list_su, *ng_node_list_sg; > - unsigned int i; > - unsigned int j; > int found; > > ng_of_su = avd_ng_get(&saAmfSUHostNodeOrNodeGroup); > @@ -397,27 +401,21 @@ static int is_config_valid(const SaNameT > return 0; > } > > - ng_node_list_su = ng_of_su->saAmfNGNodeList; > - > - for (i = 0; i < ng_of_su->number_nodes; i++) { > - found = 0; > - ng_node_list_sg = ng_of_sg->saAmfNGNodeList; > - > - for (j = 0; j < ng_of_sg->number_nodes; j++) { > - if (!memcmp(ng_node_list_su, ng_node_list_sg, > sizeof(SaNameT))) > - found = 1; > - > - ng_node_list_sg++; > + for (std::vector<SaNameT>::iterator su_iter = > ng_of_su->saAmfNGNodeList.begin(); > + su_iter != ng_of_su->saAmfNGNodeList.end(); > ++su_iter) { > + found = false; > + > + for (std::vector<SaNameT>::iterator sg_iter = > ng_of_sg->saAmfNGNodeList.begin(); > + sg_iter != ng_of_su->saAmfNGNodeList.end(); > ++sg_iter) { > + if (*su_iter == *sg_iter) > + found = true; > } > - > if (!found) { > report_ccb_validation_error(opdata, > "SU node group '%s' is not a > subset of the SG node group '%s'", > > saAmfSUHostNodeOrNodeGroup.value, saAmfSGSuHostNodeGroup.value); > return 0; > } > - > - ng_node_list_su++; > } > } > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Opensaf-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/opensaf-devel ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
