Lines Matching refs:sb
10 static void sbappendsb(struct sbuf *sb, struct mbuf *m);
21 sbfree(struct sbuf *sb) in sbfree() argument
23 free(sb->sb_data); in sbfree()
27 sbdrop(struct sbuf *sb, int num) in sbdrop() argument
33 if(num > sb->sb_cc) in sbdrop()
34 num = sb->sb_cc; in sbdrop()
35 sb->sb_cc -= num; in sbdrop()
36 sb->sb_rptr += num; in sbdrop()
37 if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen) in sbdrop()
38 sb->sb_rptr -= sb->sb_datalen; in sbdrop()
43 sbreserve(struct sbuf *sb, int size) in sbreserve() argument
45 if (sb->sb_data) { in sbreserve()
47 if (sb->sb_datalen != size) { in sbreserve()
48 sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)realloc(sb->sb_data, size); in sbreserve()
49 sb->sb_cc = 0; in sbreserve()
50 if (sb->sb_wptr) in sbreserve()
51 sb->sb_datalen = size; in sbreserve()
53 sb->sb_datalen = 0; in sbreserve()
56 sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size); in sbreserve()
57 sb->sb_cc = 0; in sbreserve()
58 if (sb->sb_wptr) in sbreserve()
59 sb->sb_datalen = size; in sbreserve()
61 sb->sb_datalen = 0; in sbreserve()
132 sbappendsb(struct sbuf *sb, struct mbuf *m) in sbappendsb() argument
138 if (sb->sb_wptr < sb->sb_rptr) { in sbappendsb()
139 n = sb->sb_rptr - sb->sb_wptr; in sbappendsb()
141 memcpy(sb->sb_wptr, m->m_data, n); in sbappendsb()
144 n = sb->sb_data + sb->sb_datalen - sb->sb_wptr; in sbappendsb()
146 memcpy(sb->sb_wptr, m->m_data, n); in sbappendsb()
150 nn = sb->sb_rptr - sb->sb_data; in sbappendsb()
152 memcpy(sb->sb_data,m->m_data+n,nn); in sbappendsb()
157 sb->sb_cc += n; in sbappendsb()
158 sb->sb_wptr += n; in sbappendsb()
159 if (sb->sb_wptr >= sb->sb_data + sb->sb_datalen) in sbappendsb()
160 sb->sb_wptr -= sb->sb_datalen; in sbappendsb()
169 sbcopy(struct sbuf *sb, int off, int len, char *to) in sbcopy() argument
173 from = sb->sb_rptr + off; in sbcopy()
174 if (from >= sb->sb_data + sb->sb_datalen) in sbcopy()
175 from -= sb->sb_datalen; in sbcopy()
177 if (from < sb->sb_wptr) { in sbcopy()
178 if (len > sb->sb_cc) len = sb->sb_cc; in sbcopy()
182 off = (sb->sb_data + sb->sb_datalen) - from; in sbcopy()
187 memcpy(to+off,sb->sb_data,len); in sbcopy()