cwmsg_vaddelem dont't needs the number of parmateres anymore.

FossilOrigin-Name: 473507160fed34042c878440b123d8f74154f8aea1d5d7c5d7572178943842d1
This commit is contained in:
7u83@mail.ru
2015-03-19 19:45:03 +00:00
parent c6aed6d463
commit e40c67a002
5 changed files with 19 additions and 13 deletions

View File

@ -22,19 +22,20 @@
#include "cwmsg.h"
void cwmsg_vaddelem(struct cwmsg *msg,int type,int n, ...)
void cwmsg_vaddelem(struct cwmsg *msg,int type, ...)
{
va_list vl;
va_start(vl,n);
int i,len=0;
for (i=0; i<n; i++){
va_start(vl,type);
int len=0;
uint8_t *data=va_arg(vl,uint8_t*);
uint8_t *data;
while ( ( data = va_arg(vl,uint8_t*)) != 0 ){
int l=va_arg(vl,int);
memcpy(msg->msgelems+4+msg->pos+len,data,l);
len+=l;
}
uint32_t val = type<<16|len;
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
msg->pos+=4+len;