#include "notify.h"
#endif /* NDEBUG */
-/* A simple sliding-window byte buffer. */
+/* A simple sliding-window byte buffer. */
typedef struct buf_ {
size_t buf_sz;
#define BUF_ROOM(__b__) ( (__b__)->buf_sz - ( (__b__)->buf_start + (__b__)->buf_used ) )
#ifndef NDEBUG
+/* For debugging, dump a buffer. */
#define D_BUF(__pre__,__b__,...) do {\
if ( (__b__) == NULL )\
NOTIFY_DEBUG(__pre__ "buf:%p", ## __VA_ARGS__, (__b__));\
#define D_BUF(...)
#endif /* NDEBUG */
-/* buf_new
- Allocate and return a new buf_t capable of holding #sz bytes.
+/* buf_new
+ Allocate and return a new buf_t capable of holding #sz bytes.
*/
buf_t buf_new(size_t sz);
-/* buf_rebase
- Reclaim any free space from the start of #buf, preserving active content.
+/* buf_del
+ Deallocate the buf_t pointed to by #pbuf.
+*/
+void buf_del(buf_t *pbuf);
+
+/* buf_rebase
+ Reclaim any free space from the start of #buf, preserving active content.
*/
void buf_rebase(buf_t buf);
-/* buf_makeroom
- Assures that the buf pointed to by #pbuf has at space to hold #roomfor more
- bytes.
+/* buf_makeroom
+ Assures that the buf pointed to by #pbuf has at space to hold #roomfor
+ more bytes.
*/
int buf_makeroom(buf_t *pbuf, size_t roomfor);
-/* buf_range_dup_or_append
- Starting at the #src_offset byte of #src, appends the following #n bytes to
- the buffer pointed to by #dstp, which will be re/allocated if needed.
+/* buf_range_dup_or_append
+ Starting at the #src_offset byte of #src, appends the following #n
+ bytes to the buffer pointed to by #dstp, which will be re/allocated if
+ needed.
*/
int buf_range_dup_or_append(buf_t src, size_t src_offset, size_t n, buf_t *pdst);
-/* buf_flense
+/* buf_flense
Starting after #src_offset characters, scan through the buffer pointed
to by #psrc, stopping at the first byte matching #delimiter, whereupon, if
#pdst is not NULL, all the bytes previous to #delimiter are appended onto