X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/11c8bf9bc50213e3774f8367ce3d5b17b2f95c49..f47cdeec5fbda82dc74d506f24e069558ee51a2c:/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,