Refactoring search code using clixon_xvec data structures

This commit is contained in:
Olof hagsand 2020-02-28 18:08:10 +01:00
parent bac2089a04
commit f1ceec689a
10 changed files with 211 additions and 175 deletions

View file

@ -90,8 +90,8 @@ main(int argc,
char *argv0 = argv[0];
int i;
cxobj *x = NULL;
cxobj **xvec = NULL;
size_t xlen = 0;
cxobj *xc;
clixon_xvec *xvec = NULL;
int c;
int len;
char *buf = NULL;
@ -244,13 +244,14 @@ main(int argc,
clicon_log(LOG_NOTICE, "%s: sort verify failed", __FUNCTION__);
}
/* Repeat for profiling (default is nr = 1) */
xvec = NULL;
for (i=0; i<nr; i++){
if (api_path_p){
if ((ret = clixon_xml_find_api_path(x, yspec, &xvec, &xlen, "%s", path)) < 0)
if ((ret = clixon_xml_find_api_path(x, yspec, &xvec, "%s", path)) < 0)
goto done;
}
else{
if ((ret = clixon_xml_find_instance_id(x, yspec, &xvec, &xlen, "%s", path)) < 0)
if ((ret = clixon_xml_find_instance_id(x, yspec, &xvec, "%s", path)) < 0)
goto done;
}
if (ret == 0){
@ -259,9 +260,10 @@ main(int argc,
}
}
/* Print results */
for (i=0; i<xlen; i++){
for (i=0; i<clixon_xvec_len(xvec); i++){
xc = clixon_xvec_i(xvec,i);
fprintf(stdout, "%d: ", i);
clicon_xml2file(stdout, xvec[i], 0, 0);
clicon_xml2file(stdout, xc, 0, 0);
fprintf(stdout, "\n");
fflush(stdout);
}
@ -272,7 +274,7 @@ main(int argc,
if (cb)
cbuf_free(cb);
if (xvec)
free(xvec);
clixon_xvec_free(xvec);
if (buf)
free(buf);
if (x)