Commit 907e01d6 authored by Evan Hunt's avatar Evan Hunt
Browse files

[master] buffer ATF test was failing

parent ed51a217
......@@ -505,20 +505,21 @@ isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size) {
REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
len = (*dynbuffer)->length;
if ((len - (*dynbuffer)->used) > size)
if ((len - (*dynbuffer)->used) >= size)
return (ISC_R_SUCCESS);
/* Round to nearest buffer size increment */
len += size;
len = size + (*dynbuffer)->used;
len = (len + ISC_BUFFER_INCR - 1 - ((len - 1) % ISC_BUFFER_INCR));
/* Cap at UINT_MAX */
if (len > UINT_MAX) {
len = UINT_MAX;
if ((len - (*dynbuffer)->used) < size)
return (ISC_R_NOMEMORY);
}
if ((len - (*dynbuffer)->used) < size)
return (ISC_R_NOMEMORY);
return (isc_buffer_reallocate(dynbuffer, (unsigned int) len));
}
......
......@@ -67,7 +67,7 @@ ATF_TC_BODY(isc_buffer_reserve, tc) {
* 2048 bytes should already be available, so this call does
* nothing.
*/
result = isc_buffer_reserve(&b, 2048);
result = isc_buffer_reserve(&b, 2000);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
ATF_CHECK(ISC_BUFFER_VALID(b));
......@@ -77,7 +77,7 @@ ATF_TC_BODY(isc_buffer_reserve, tc) {
* This call should grow it to 4096 bytes as only 2048 bytes are
* available in the buffer.
*/
result = isc_buffer_reserve(&b, 2049);
result = isc_buffer_reserve(&b, 3000);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
ATF_CHECK(ISC_BUFFER_VALID(b));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment