fd_read_to_ibuf | ibuf_init | ibuf_rewind | ibuf_xread |
ibuf_buffer | ibuf_length | ibuf_write | p_ibuf |
ibuf_free | ibuf_read | ibuf_write_block |
Ibuffer fd_read_to_ibuf(int fd);
int *ibuf_buffer(Ibuffer ibuf);
void ibuf_free(Ibuffer ibuf);Free an Ibuffer.
Ibuffer ibuf_init(void);Allocate and initialize an Ibuffer.
int ibuf_length(Ibuffer ibuf);
int ibuf_read(Ibuffer ibuf);Get the next integer from an Ibuffer. This version returns IBUF_EOF (INT_MIN) if there is nothing to read.
void ibuf_rewind(Ibuffer ibuf);Reset an Ibuffer for reading.
void ibuf_write(Ibuffer ibuf, int i);Write an integer to an Ibuffer.
void ibuf_write_block(Ibuffer ibuf, int *a, int n);Write an array of integers to an Ibuffer.
int ibuf_xread(Ibuffer ibuf);Get the next integer from an Ibuffer. This version assumes there is an integer to read; if it is at the end IBUF_EOF, a fatal error occurs.
void p_ibuf(Ibuffer ibuf);Print a an Ibuffer to a stdout. This is mainly for debugging.
#define IBUF_INIT_SIZE 40000 #define IBUF_EOF INT_MIN struct ibuffer { int write_position; /* current number of ints in buf (next pos to write) */ int read_position; /* next pos to read */ int size; /* size of buf */ int *buf; /* the buffer */ }; typedef struct ibuffer * Ibuffer;