--- sbbs/src/sbbs3/ringbuf.c 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/ringbuf.c 2018/04/24 16:43:11 1.1.1.2 @@ -2,7 +2,7 @@ /* Synchronet ring buffer routines */ -/* $Id: ringbuf.c,v 1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: ringbuf.c,v 1.1.1.2 2018/04/24 16:43:11 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * @@ -147,15 +147,6 @@ DWORD RINGBUFCALL RingBufFull( RingBuf* retval = RINGBUF_FILL_LEVEL(rb); -#ifdef RINGBUF_EVENT - if(rb->empty_event!=NULL) { - if(retval==0) - SetEvent(rb->empty_event); - else - ResetEvent(rb->empty_event); - } -#endif - #ifdef RINGBUF_MUTEX pthread_mutex_unlock(&rb->mutex); #endif @@ -176,6 +167,9 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* { DWORD max, first, remain; + if(cnt==0) + return(cnt); + if(rb->pStart==NULL) return(0); @@ -184,7 +178,7 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* #endif /* allowed to write at pEnd */ - max = (((DWORD) rb->pEnd) - ((DWORD) rb->pHead)) + 1; + max = rb->pEnd - rb->pHead + 1; /* * we assume the caller has checked that there is enough room. For this reason @@ -245,7 +239,7 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* cnt = len; /* allowed to read at pEnd */ - max = (((DWORD) rb->pEnd) - ((DWORD) rb->pTail)) + 1; + max = rb->pEnd - rb->pTail + 1; if( max >= cnt ) { first = cnt; @@ -307,7 +301,7 @@ DWORD RINGBUFCALL RingBufPeek( RingBuf* cnt = len; /* allowed to read at pEnd */ - max = (((DWORD) rb->pEnd) - ((DWORD) rb->pTail)) + 1; + max = rb->pEnd - rb->pTail + 1; if( max >= cnt ) { first = cnt;