version 1.23, 2011/10/12 07:20:03 |
version 1.24, 2012/04/11 06:05:43 |
|
|
#endif |
#endif |
|
|
struct abuf * |
struct abuf * |
abuf_new(unsigned nfr, struct aparams *par) |
abuf_new(unsigned int nfr, struct aparams *par) |
{ |
{ |
struct abuf *buf; |
struct abuf *buf; |
unsigned len, bpf; |
unsigned int len, bpf; |
|
|
bpf = aparams_bpf(par); |
bpf = aparams_bpf(par); |
len = nfr * bpf; |
len = nfr * bpf; |
|
|
* Get a pointer to the readable block at the given offset. |
* Get a pointer to the readable block at the given offset. |
*/ |
*/ |
unsigned char * |
unsigned char * |
abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) |
abuf_rgetblk(struct abuf *buf, unsigned int *rsize, unsigned int ofs) |
{ |
{ |
unsigned count, start, used; |
unsigned int count, start, used; |
|
|
start = buf->start + ofs; |
start = buf->start + ofs; |
used = buf->used - ofs; |
used = buf->used - ofs; |
|
|
* Discard the block at the start postion. |
* Discard the block at the start postion. |
*/ |
*/ |
void |
void |
abuf_rdiscard(struct abuf *buf, unsigned count) |
abuf_rdiscard(struct abuf *buf, unsigned int count) |
{ |
{ |
#ifdef DEBUG |
#ifdef DEBUG |
if (count > buf->used) { |
if (count > buf->used) { |
|
|
* Commit the data written at the end postion. |
* Commit the data written at the end postion. |
*/ |
*/ |
void |
void |
abuf_wcommit(struct abuf *buf, unsigned count) |
abuf_wcommit(struct abuf *buf, unsigned int count) |
{ |
{ |
#ifdef DEBUG |
#ifdef DEBUG |
if (count > (buf->len - buf->used)) { |
if (count > (buf->len - buf->used)) { |
|
|
* Get a pointer to the writable block at offset ofs. |
* Get a pointer to the writable block at offset ofs. |
*/ |
*/ |
unsigned char * |
unsigned char * |
abuf_wgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) |
abuf_wgetblk(struct abuf *buf, unsigned int *rsize, unsigned int ofs) |
{ |
{ |
unsigned end, avail, count; |
unsigned int end, avail, count; |
|
|
|
|
end = buf->start + buf->used + ofs; |
end = buf->start + buf->used + ofs; |