+/* FIXME: unsigned char -> byte everywhere */
+
+
+int adns__vbuf_ensure(adns__vbuf *vb, size_t want) {
+ byte *nb;
+
+ if (vb->avail >= want) return;
+ nb= realloc(vb->buf,want); if (!nb) return 0;
+ vb->buf= nb;
+ vb->avail= want;
+ return 1;
+}
+
+void adns__vbuf_appendq(adns__vbuf *vb, const byte *data, size_t len) {
+ memcpy(vb->buf+vb->used,data,len);
+ vb->used+= len;
+}
+
+int adns__vbuf_append(adns__vbuf *vb, const byte *data, size_t len) {
+ size_t newlen, newalloc;
+ byte *nb;
+
+ newlen= vb->used+len;
+ if (vb->avail < newlen) {
+ newlen <<= 1;
+ nb= realloc(vb->buf,newlen);
+ if (!nb) { newlen >>= 1; nb= realloc(vb->buf,newlen); }
+ if (!nb) return 0;
+ vb->buf= nb;
+ vb->avail= newlen;
+ }
+ adns__vbuf_appendq(vb,data,len);
+ return 1;
+}
+