X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fwrbuf.c;h=135c0472a4d6744c8b8d2f6a191eca77c4103e72;hb=a3e65bcd3250b107397675bc65b35b5939355025;hp=67de45e5cf9c1d69bca221141ae6cd296a9d765a;hpb=38d2e7b4d30b060d3b6dc85e0e3f57c4930c6313;p=yaz-moved-to-github.git diff --git a/src/wrbuf.c b/src/wrbuf.c index 67de45e..135c047 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) 1995-2012 Index Data * See the file LICENSE for details. */ @@ -74,6 +74,17 @@ void wrbuf_write(WRBUF b, const char *buf, size_t size) b->pos += size; } +void wrbuf_insert(WRBUF b, size_t pos, const char *buf, size_t size) +{ + if (size <= 0 || pos > b->pos) + return; + if (b->pos + size >= b->size) + wrbuf_grow(b, size); + memmove(b->buf + pos + size, b->buf + pos, b->pos - pos); + memcpy(b->buf + pos, buf, size); + b->pos += size; +} + void wrbuf_puts(WRBUF b, const char *buf) { wrbuf_write(b, buf, strlen(buf));