X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/3955725ceceb330041f8e7a27e6629a2e8a9b5ba..a49a6d7b1f7da9722082778d6694ccbc077d262a:/src/general.c diff --git a/src/general.c b/src/general.c index 2ced4c0..9db4bb4 100644 --- a/src/general.c +++ b/src/general.c @@ -111,9 +111,10 @@ int adns__vbuf_append(vbuf *vb, const byte *data, int len) { newlen= vb->used+len; if (vb->avail < newlen) { + if (newlen<20) newlen= 20; newlen <<= 1; nb= realloc(vb->buf,newlen); - if (!nb) { newlen >>= 1; nb= realloc(vb->buf,newlen); } + if (!nb) { newlen= vb->used+len; nb= realloc(vb->buf,newlen); } if (!nb) return 0; vb->buf= nb; vb->avail= newlen; @@ -122,6 +123,11 @@ int adns__vbuf_append(vbuf *vb, const byte *data, int len) { return 1; } +void adns__vbuf_free(vbuf *vb) { + free(vb->buf); + adns__vbuf_init(vb); +} + /* Additional diagnostic functions */ const char *adns__diag_domain(adns_state ads, int serv, adns_query qu, vbuf *vb,