| // SPDX-License-Identifier: GPL-2.0+ |
| * Gerry Hamel, geh@ti.com, Texas Instruments |
| int buf_init (circbuf_t * buf, unsigned int size) |
| buf->data = (char *) malloc (sizeof (char) * size); |
| assert (buf->data != NULL); |
| buf->end = &(buf->data[size]); |
| int buf_free (circbuf_t * buf) |
| assert (buf->data != NULL); |
| memset (buf, 0, sizeof (circbuf_t)); |
| int buf_pop (circbuf_t * buf, char *dest, unsigned int len) |
| /* Cap to number of bytes in buffer */ |
| for (i = 0; i < len; i++) { |
| /* Update 'top' pointer */ |
| int buf_push (circbuf_t * buf, const char *src, unsigned int len) |
| /* NOTE: this function allows push to overwrite old data. */ |
| for (i = 0; i < len; i++) { |
| /* Make sure pushing too much data just replaces old data */ |
| if (buf->size < buf->totalsize) { |
| if (buf->top == buf->end) { |
| /* Update 'tail' pointer */ |