comparison circbuffer.c @ 594:a98a2138364a

Improve capitalisation for all logged strings
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Feb 2011 15:50:30 +0000
parents c5d3ef11155f
children 4222a1039b06
comparison
equal deleted inserted replaced
593:ea103e4476ce 594:a98a2138364a
31 circbuffer * cbuf_new(unsigned int size) { 31 circbuffer * cbuf_new(unsigned int size) {
32 32
33 circbuffer *cbuf = NULL; 33 circbuffer *cbuf = NULL;
34 34
35 if (size > MAX_CBUF_SIZE) { 35 if (size > MAX_CBUF_SIZE) {
36 dropbear_exit("bad cbuf size"); 36 dropbear_exit("Bad cbuf size");
37 } 37 }
38 38
39 cbuf = (circbuffer*)m_malloc(sizeof(circbuffer)); 39 cbuf = (circbuffer*)m_malloc(sizeof(circbuffer));
40 cbuf->data = (unsigned char*)m_malloc(size); 40 cbuf->data = (unsigned char*)m_malloc(size);
41 cbuf->used = 0; 41 cbuf->used = 0;
99 return cbuf->size - cbuf->writepos; 99 return cbuf->size - cbuf->writepos;
100 } 100 }
101 101
102 unsigned char* cbuf_readptr(circbuffer *cbuf, unsigned int len) { 102 unsigned char* cbuf_readptr(circbuffer *cbuf, unsigned int len) {
103 if (len > cbuf_readlen(cbuf)) { 103 if (len > cbuf_readlen(cbuf)) {
104 dropbear_exit("bad cbuf read"); 104 dropbear_exit("Bad cbuf read");
105 } 105 }
106 106
107 return &cbuf->data[cbuf->readpos]; 107 return &cbuf->data[cbuf->readpos];
108 } 108 }
109 109
110 unsigned char* cbuf_writeptr(circbuffer *cbuf, unsigned int len) { 110 unsigned char* cbuf_writeptr(circbuffer *cbuf, unsigned int len) {
111 111
112 if (len > cbuf_writelen(cbuf)) { 112 if (len > cbuf_writelen(cbuf)) {
113 dropbear_exit("bad cbuf write"); 113 dropbear_exit("Bad cbuf write");
114 } 114 }
115 115
116 return &cbuf->data[cbuf->writepos]; 116 return &cbuf->data[cbuf->writepos];
117 } 117 }
118 118
119 void cbuf_incrwrite(circbuffer *cbuf, unsigned int len) { 119 void cbuf_incrwrite(circbuffer *cbuf, unsigned int len) {
120 if (len > cbuf_writelen(cbuf)) { 120 if (len > cbuf_writelen(cbuf)) {
121 dropbear_exit("bad cbuf write"); 121 dropbear_exit("Bad cbuf write");
122 } 122 }
123 123
124 cbuf->used += len; 124 cbuf->used += len;
125 dropbear_assert(cbuf->used <= cbuf->size); 125 dropbear_assert(cbuf->used <= cbuf->size);
126 cbuf->writepos = (cbuf->writepos + len) % cbuf->size; 126 cbuf->writepos = (cbuf->writepos + len) % cbuf->size;
127 } 127 }
128 128
129 129
130 void cbuf_incrread(circbuffer *cbuf, unsigned int len) { 130 void cbuf_incrread(circbuffer *cbuf, unsigned int len) {
131 if (len > cbuf_readlen(cbuf)) { 131 if (len > cbuf_readlen(cbuf)) {
132 dropbear_exit("bad cbuf read"); 132 dropbear_exit("Bad cbuf read");
133 } 133 }
134 134
135 dropbear_assert(cbuf->used >= len); 135 dropbear_assert(cbuf->used >= len);
136 cbuf->used -= len; 136 cbuf->used -= len;
137 cbuf->readpos = (cbuf->readpos + len) % cbuf->size; 137 cbuf->readpos = (cbuf->readpos + len) % cbuf->size;