From f73262b3b52532d68409897284c276520c71566a Mon Sep 17 00:00:00 2001 From: rd235 Date: Wed, 7 Nov 2007 08:09:03 +0000 Subject: [PATCH] Function-like definition of BA_REALLOC, bugfix in BAC_COPY git-svn-id: https://vde.svn.sourceforge.net/svnroot/vde/trunk@204 d37a7db1-d92d-0410-89df-f68f52f87b57 --- vde-2/bitarray.h | 7 ++++--- vde-2/fstp.c | 12 ++++++------ vde-2/port.c | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/vde-2/bitarray.h b/vde-2/bitarray.h index a77f528..cc54d48 100644 --- a/vde-2/bitarray.h +++ b/vde-2/bitarray.h @@ -85,6 +85,7 @@ typedef unsigned long bitarrayelem; typedef bitarrayelem *bitarray; /* Simple Bit Array */ + #define BA_ALLOC(N) (calloc(__WORDSIZEROUND(N),sizeof(unsigned long))) #define BA_REALLOC(B,N,M) \ @@ -94,7 +95,7 @@ typedef bitarrayelem *bitarray; for(__i=__WORDSIZEROUND(N);__i<__WORDSIZEROUND(M);__i++) \ nb[__i]=0; \ nb[__WORDSIZEROUND(N)-1] &= (1<<(((((N)&__WORDSIZEMASK)-1)&0x1f)+1))-1; \ - (B)=nb;}) + nb;}) #define BA_CHECK(X,I) ((X) && ((X)[(I)>>__LOG_WORDSIZE] & (1 << ((I) & __WORDSIZEMASK)))) @@ -183,7 +184,7 @@ typedef bitarrayelem *bitarray; for(__i=__WORDSIZEROUND(N);__i<__WORDSIZEROUND(M);__i++) \ nb[__i]=0; }\ nb[__WORDSIZEROUND(N)-1] &= (1<<(((((N)&__WORDSIZEMASK)-1)&0x1f)+1))-1; \ - (B)=nb;}) + nb;}) /* BA_CHECK and BAC_CHECK are the same */ #define BAC_CHECK(X,I) ((X) && ((X)[(I)>>__LOG_WORDSIZE] & (1 << ((I) & __WORDSIZEMASK)))) @@ -231,7 +232,7 @@ typedef bitarrayelem *bitarray; #define BAC_CARD(X,N) ((X)[__WORDSIZEROUND(N)]) #define BAC_EMPTY(X,N) ((X)[__WORDSIZEROUND(N)]==0) -#define BAC_COPY(DST,SRC,N) memcpy(DST,SRC,sizeof(bitarrayelem) * __WORDSIZEROUND(N)) +#define BAC_COPY(DST,SRC,N) memcpy(DST,SRC,sizeof(bitarrayelem) * (__WORDSIZEROUND(N)+1)) #if 0 /* usage example */ diff --git a/vde-2/fstp.c b/vde-2/fstp.c index a09600d..1e9f582 100644 --- a/vde-2/fstp.c +++ b/vde-2/fstp.c @@ -241,32 +241,32 @@ void fstsetnumports (int val) /*printf("F numports %d\n",val);*/ for (i=0;iuntag,numports,val); + fsttab[i]->untag=BA_REALLOC(fsttab[i]->untag,numports,val); if (fsttab[i]->untag == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/untag %s",strerror(errno)); exit(1); } - BA_REALLOC(fsttab[i]->tagged,numports,val); + fsttab[i]->tagged=BA_REALLOC(fsttab[i]->tagged,numports,val); if (fsttab[i]->tagged == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/tagged %s",strerror(errno)); exit(1); } - BA_REALLOC(fsttab[i]->backup,numports,val); + fsttab[i]->backup=BA_REALLOC(fsttab[i]->backup,numports,val); if (fsttab[i]->backup == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/backup %s",strerror(errno)); exit(1); } - BA_REALLOC(fsttab[i]->edge,numports,val); + fsttab[i]->edge=BA_REALLOC(fsttab[i]->edge,numports,val); if (fsttab[i]->edge == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/edge %s",strerror(errno)); exit(1); } - BA_REALLOC(fsttab[i]->rcvhist[0],numports,val); + fsttab[i]->rcvhist[0]=BA_REALLOC(fsttab[i]->rcvhist[0],numports,val); if (fsttab[i]->rcvhist[0] == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/rcvhist0 %s",strerror(errno)); exit(1); } - BA_REALLOC(fsttab[i]->rcvhist[1],numports,val); + fsttab[i]->rcvhist[1]=BA_REALLOC(fsttab[i]->rcvhist[1],numports,val); if (fsttab[i]->rcvhist[1] == NULL) { printlog(LOG_ERR,"Numport resize failed vlan tables fstab/rcvhist1 %s",strerror(errno)); exit(1); diff --git a/vde-2/port.c b/vde-2/port.c index 9508240..78a3b0a 100644 --- a/vde-2/port.c +++ b/vde-2/port.c @@ -555,21 +555,21 @@ static int portsetnumports(int val) } for (i=0;i