diff --git a/crypto/buf/buf.c b/crypto/buf/buf.c index 5addc79e..6b871e21 100644 --- a/crypto/buf/buf.c +++ b/crypto/buf/buf.c @@ -86,7 +86,7 @@ void BUF_MEM_free(BUF_MEM *buf) { OPENSSL_free(buf); } -static int buf_mem_reserve(BUF_MEM *buf, size_t cap, int clean) { +int BUF_MEM_reserve(BUF_MEM *buf, size_t cap) { if (buf->max >= cap) { return 1; } @@ -116,12 +116,8 @@ static int buf_mem_reserve(BUF_MEM *buf, size_t cap, int clean) { return 1; } -int BUF_MEM_reserve(BUF_MEM *buf, size_t cap) { - return buf_mem_reserve(buf, cap, 0 /* don't clear old buffer contents. */); -} - -static size_t buf_mem_grow(BUF_MEM *buf, size_t len, int clean) { - if (!buf_mem_reserve(buf, len, clean)) { +size_t BUF_MEM_grow(BUF_MEM *buf, size_t len) { + if (!BUF_MEM_reserve(buf, len)) { return 0; } if (buf->length < len) { @@ -131,12 +127,8 @@ static size_t buf_mem_grow(BUF_MEM *buf, size_t len, int clean) { return len; } -size_t BUF_MEM_grow(BUF_MEM *buf, size_t len) { - return buf_mem_grow(buf, len, 0 /* don't clear old buffer contents. */); -} - size_t BUF_MEM_grow_clean(BUF_MEM *buf, size_t len) { - return buf_mem_grow(buf, len, 1 /* clear old buffer contents. */); + return BUF_MEM_grow(buf, len); } char *BUF_strdup(const char *str) { diff --git a/include/openssl/buf.h b/include/openssl/buf.h index d4c3e221..c4d0bc76 100644 --- a/include/openssl/buf.h +++ b/include/openssl/buf.h @@ -89,8 +89,8 @@ OPENSSL_EXPORT int BUF_MEM_reserve(BUF_MEM *buf, size_t cap); // zeros. It returns the length of |buf|, or zero if there's an error. OPENSSL_EXPORT size_t BUF_MEM_grow(BUF_MEM *buf, size_t len); -// BUF_MEM_grow_clean acts the same as |BUF_MEM_grow|, but clears the previous -// contents of memory if reallocing. +// BUF_MEM_grow_clean calls |BUF_MEM_grow|. BoringSSL always zeros memory +// allocated memory on free. OPENSSL_EXPORT size_t BUF_MEM_grow_clean(BUF_MEM *buf, size_t len); // BUF_strdup returns an allocated, duplicate of |str|.