circbuf.h 705 B

123456789101112131415161718192021222324252627
  1. /*
  2. * (C) Copyright 2003
  3. * Gerry Hamel, geh@ti.com, Texas Instruments
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __CIRCBUF_H__
  8. #define __CIRCBUF_H__
  9. typedef struct circbuf {
  10. unsigned int size; /* current number of bytes held */
  11. unsigned int totalsize; /* number of bytes allocated */
  12. char *top; /* pointer to current buffer start */
  13. char *tail; /* pointer to space for next element */
  14. char *data; /* all data */
  15. char *end; /* end of data buffer */
  16. } circbuf_t;
  17. int buf_init (circbuf_t * buf, unsigned int size);
  18. int buf_free (circbuf_t * buf);
  19. int buf_pop (circbuf_t * buf, char *dest, unsigned int len);
  20. int buf_push (circbuf_t * buf, const char *src, unsigned int len);
  21. #endif