Ejemplo n.º 1
0
int printbuf_memappend(struct printbuf *p, char *buf, int size)
{
    char *t;
    if(p->size - p->bpos <= size) {
        int new_size = MAX(p->size * 2, p->bpos + size + 8);
#ifdef PRINTBUF_DEBUG
        mc_debug("printbuf_memappend: realloc "
                 "bpos=%d wrsize=%d old_size=%d new_size=%d\n",
                 p->bpos, size, p->size, new_size);
#endif /* PRINTBUF_DEBUG */
        if(!(t = realloc(p->buf, new_size))) return -1;
        p->size = new_size;
        p->buf = t;
    }
    memcpy(p->buf + p->bpos, buf, size);
    p->bpos += size;
    p->buf[p->bpos]= '\0';
    return size;
}
Ejemplo n.º 2
0
int main(void)
{
    debug("hello %d, %s, %f\n", 1, "shit", 1.0);
    mc_debug("test %s", "helo world");
}