comparison circbuffer.c @ 165:0cfba3034be5

Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
author Matt Johnston <matt@ucc.asn.au>
date Sun, 02 Jan 2005 20:25:56 +0000
parents 10f4d3319780
children c5d3ef11155f
comparison
equal deleted inserted replaced
161:b9d3f725e00b 165:0cfba3034be5
68 68
69 assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size); 69 assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
70 assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size); 70 assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
71 71
72 if (cbuf->used == 0) { 72 if (cbuf->used == 0) {
73 TRACE(("cbuf_readlen: unused buffer")); 73 TRACE(("cbuf_readlen: unused buffer"))
74 return 0; 74 return 0;
75 } 75 }
76 76
77 if (cbuf->readpos < cbuf->writepos) { 77 if (cbuf->readpos < cbuf->writepos) {
78 return cbuf->writepos - cbuf->readpos; 78 return cbuf->writepos - cbuf->readpos;
86 assert(cbuf->used <= cbuf->size); 86 assert(cbuf->used <= cbuf->size);
87 assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size); 87 assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
88 assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size); 88 assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
89 89
90 if (cbuf->used == cbuf->size) { 90 if (cbuf->used == cbuf->size) {
91 TRACE(("cbuf_writelen: full buffer")); 91 TRACE(("cbuf_writelen: full buffer"))
92 return 0; /* full */ 92 return 0; /* full */
93 } 93 }
94 94
95 if (cbuf->writepos < cbuf->readpos) { 95 if (cbuf->writepos < cbuf->readpos) {
96 return cbuf->readpos - cbuf->writepos; 96 return cbuf->readpos - cbuf->writepos;