# printbuf.h File Reference

## Data Structures

struct | printbuf

## Defines

#define | printbuf_memappend_fast(p, bufptr, bufsize)
#define | printbuf_length(p) ((p)->bpos)

## Functions

struct printbuf * | printbuf_new (void)
int | printbuf_memappend (struct printbuf *p, const char *buf, int size)
int | printbuf_memset (struct printbuf *pb, int offset, int charvalue, int len)
int | sprintbuf (struct printbuf *p, const char *msg,...)
void | printbuf_reset (struct printbuf *p)
void | printbuf_free (struct printbuf *p)

## Define Documentation

#define printbuf_length | ( | p |  | ) | ((p)->bpos)

#define printbuf_memappend_fast | ( | p,
|  | bufptr,
|  | bufsize |  | ) |

Value:

    do {                                                         \
      if ((p->size - p->bpos) > bufsize) {                       \
        memcpy(p->buf + p->bpos, (bufptr), bufsize);             \
        p->bpos += bufsize;                                      \
        p->buf[p->bpos]= '\0';                                   \
      } else {  printbuf_memappend(p, (bufptr), bufsize); }      \
    } while (0)

## Function Documentation

void printbuf_free | ( | struct printbuf * | p | ) |

int printbuf_memappend | ( | struct printbuf * | p,
|  | const char * | buf,
|  | int | size |
| ) |  |  |

int printbuf_memset | ( | struct printbuf * | pb,
|  | int | offset,
|  | int | charvalue,
|  | int | len |
| ) |  |  |

Set len bytes of the buffer to charvalue, starting at offset offset. Similar to calling memset(x, charvalue, len);

The memory allocated for the buffer is extended as necessary.

If offset is -1, this starts at the end of the current data in the buffer.

struct printbuf* printbuf_new | ( | void |  | ) | `[read]`

void printbuf_reset | ( | struct printbuf * | p | ) |

int sprintbuf | ( | struct printbuf * | p,
|  | const char * | msg,
|  |  | ... |
| ) |  |  |