From: Adam Heath Date: Mon, 1 Jan 2001 08:08:56 +0000 (+0000) Subject: Add varbufdupc(). X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb45fbbd58961bdbe71bc2b4a85d5bdc6700eda4;p=dpkg Add varbufdupc(). --- diff --git a/ChangeLog b/ChangeLog index c44705b9..6cfcd87f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -Mon Jan 1 02:04:26 CST 2001 Wichert Akkerman +Mon Jan 1 02:07:47 CST 2001 Adam Heath + + * lib/varbuf.c, include/dpkg-db.h: Add varbufdupc(). + +Mon Jan 1 02:04:26 CST 2001 Adam Heath * lib/parse.c: Use of PKGIOFF macro was checked in prematurely. diff --git a/include/dpkg-db.h b/include/dpkg-db.h index d75cfbe9..bece2d04 100644 --- a/include/dpkg-db.h +++ b/include/dpkg-db.h @@ -225,6 +225,7 @@ const char *versiondescribe(const struct versionrevision*, struct varbuf; extern void varbufaddc(struct varbuf *v, int c); +extern void varbufdupc(struct varbuf *v, int c, ssize_t s); void varbufinit(struct varbuf *v); void varbufreset(struct varbuf *v); void varbufextend(struct varbuf *v); diff --git a/lib/varbuf.c b/lib/varbuf.c index 0c8f1770..ed33837b 100644 --- a/lib/varbuf.c +++ b/lib/varbuf.c @@ -32,6 +32,17 @@ void varbufaddc(struct varbuf *v, int c) { v->buf[v->used++]= c; } +void varbufdupc(struct varbuf *v, int c, ssize_t n) { + char *b = v->buf + v->used; + v->used += n; + if (v->used >= v->size) varbufextend(v); + + while(n) { + *b= c; + b++; n--; + } +} + void varbufprintf(struct varbuf *v, const char *fmt, ...) { int ou, r; va_list al;