C-API: Changed type of veclen parameter to size_t in xpath_vec_flag()

Rewrite of sed -e to be portable to freebsd
This commit is contained in:
Olof hagsand 2022-12-29 15:45:16 +01:00
parent 5b9921933a
commit 6fedf65de7
8 changed files with 23 additions and 14 deletions

View file

@ -332,10 +332,13 @@ clixon_event_poll(int fd)
}
/*! Dispatch file descriptor events (and timeouts) by invoking callbacks.
* There is an issue with fairness that timeouts may take over all events
* One could try to poll the file descriptors after a timeout?
* @retval 0 OK
* @retval -1 Error: eg select, callback, timer,
*
* @param[in] h Clixon handle
* @retval 0 OK
* @retval -1 Error: eg select, callback, timer,
* @note There is an issue with fairness between timeouts and events
* Currently a socket that is not read/emptied properly starve timeouts.
* One could try to poll the file descriptors after a timeout?
*/
int
clixon_event_loop(clicon_handle h)

View file

@ -370,6 +370,7 @@ xml_default(yang_stmt *yt,
case Y_CHOICE:{
if (xml_default_choice(yc, xt, state) < 0)
goto done;
break;
}
default:
break;

View file

@ -823,7 +823,7 @@ xpath_vec(cxobj *xcur,
* @retval -1 error.
* @code
* cxobj **vec;
* int veclen;
* size_t veclen;
* cvec *nsc; // namespace context (not NULL)
* if (xpath_vec_flag(xcur, nsc, "//symbol/foo", XML_FLAG_ADD, &vec, &veclen) < 0)
* goto err;
@ -842,7 +842,7 @@ xpath_vec_flag(cxobj *xcur,
const char *xpformat,
uint16_t flags,
cxobj ***vec,
int *veclen,
size_t *veclen,
...)
{
int retval = -1;
@ -852,6 +852,7 @@ xpath_vec_flag(cxobj *xcur,
xp_ctx *xr = NULL;
int i;
cxobj *x;
int ilen = 0; /* change when cxvec_append uses size_t */
va_start(ap, veclen);
len = vsnprintf(NULL, 0, xpformat, ap);
@ -870,17 +871,18 @@ xpath_vec_flag(cxobj *xcur,
}
va_end(ap);
*vec=NULL;
*veclen = 0;
if (xpath_vec_ctx(xcur, nsc, xpath, 0, &xr) < 0)
goto done;
if (xr && xr->xc_type == XT_NODESET){
for (i=0; i<xr->xc_size; i++){
int ilen;
x = xr->xc_nodeset[i];
if (flags==0x0 || xml_flag(x, flags))
if (cxvec_append(x, vec, veclen) < 0)
if (cxvec_append(x, vec, &ilen) < 0)
goto done;
}
}
*veclen = ilen;
retval = 0;
done:
if (xr)