From d9e4d5cb7c2ef48f89335d80dcb72d2b127869c5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 7 Mar 2014 09:33:31 +0100 Subject: [PATCH] src/openvz: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT Signed-off-by: Michal Privoznik --- src/openvz/openvz_conf.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 0ea8243a24..11f048bd1f 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -232,10 +232,8 @@ openvzReadNetworkConf(virDomainDefPtr def, if (VIR_STRDUP(net->data.ethernet.ipaddr, token) < 0) goto error; - if (VIR_REALLOC_N(def->nets, def->nnets + 1) < 0) + if (VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, net) < 0) goto error; - def->nets[def->nnets++] = net; - net = NULL; token = strtok_r(NULL, " ", &saveptr); } @@ -326,10 +324,8 @@ openvzReadNetworkConf(virDomainDefPtr def, p = ++next; } while (p < token + strlen(token)); - if (VIR_REALLOC_N(def->nets, def->nnets + 1) < 0) + if (VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, net) < 0) goto error; - def->nets[def->nnets++] = net; - net = NULL; token = strtok_r(NULL, ";", &saveptr); } @@ -450,10 +446,8 @@ openvzReadFSConf(virDomainDefPtr def, } } - if (VIR_REALLOC_N(def->fss, def->nfss + 1) < 0) + if (VIR_APPEND_ELEMENT(def->fss, def->nfss, fs) < 0) goto error; - def->fss[def->nfss++] = fs; - fs = NULL; VIR_FREE(temp);