aux: remove DynIOBuffer::allocated

This largely reverts commit 8cfde80759.

Updates #135
This commit is contained in:
Nigel Tao committed 2024-04-05 15:54:33 +11:00
1 parent 00a01abc4e
commit d8c3deb028
3 files changed
+8 -34

No files matched your search

+4 -15
View File
@@ -25,16 +25,12 @@ DynIOBuffer::DynIOBuffer(uint64_t max_incl)
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
DynIOBuffer::~DynIOBuffer() {
if (allocated()) {
free(m_buf.data.ptr);
}
free(m_buf.data.ptr);
}
void //
DynIOBuffer::drop() {
if (allocated()) {
free(m_buf.data.ptr);
}
free(m_buf.data.ptr);
m_buf = wuffs_base__empty_io_buffer();
}
@@ -48,9 +44,8 @@ DynIOBuffer::grow(uint64_t min_incl) {
} else if (n > SIZE_MAX) {
return DynIOBuffer::GrowResult::FailedOutOfMemory;
} else if (n > m_buf.data.len) {
uint8_t* ptr = static_cast<uint8_t*>(
allocated() ? realloc(m_buf.data.ptr, static_cast<size_t>(n))
: malloc(static_cast<size_t>(n)));
uint8_t* ptr =
static_cast<uint8_t*>(realloc(m_buf.data.ptr, static_cast<size_t>(n)));
if (!ptr) {
return DynIOBuffer::GrowResult::FailedOutOfMemory;
}
@@ -60,12 +55,6 @@ DynIOBuffer::grow(uint64_t min_incl) {
return DynIOBuffer::GrowResult::OK;
}
bool //
DynIOBuffer::allocated() {
IOBuffer buf = wuffs_base__empty_io_buffer();
return buf.data.ptr != m_buf.data.ptr;
}
// round_up rounds min_incl up, returning the smallest value x satisfying
// (min_incl <= x) and (x <= max_incl) and some other constraints. It returns 0
// if there is no such x.
-2
View File
@@ -84,8 +84,6 @@ class DynIOBuffer {
DynIOBuffer(const DynIOBuffer&) = delete;
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
bool allocated();
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
};
+4 -17
View File
@@ -14440,8 +14440,6 @@ class DynIOBuffer {
DynIOBuffer(const DynIOBuffer&) = delete;
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
bool allocated();
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
};
@@ -72077,16 +72075,12 @@ DynIOBuffer::DynIOBuffer(uint64_t max_incl)
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
DynIOBuffer::~DynIOBuffer() {
if (allocated()) {
free(m_buf.data.ptr);
}
free(m_buf.data.ptr);
}
void //
DynIOBuffer::drop() {
if (allocated()) {
free(m_buf.data.ptr);
}
free(m_buf.data.ptr);
m_buf = wuffs_base__empty_io_buffer();
}
@@ -72100,9 +72094,8 @@ DynIOBuffer::grow(uint64_t min_incl) {
} else if (n > SIZE_MAX) {
return DynIOBuffer::GrowResult::FailedOutOfMemory;
} else if (n > m_buf.data.len) {
uint8_t* ptr = static_cast<uint8_t*>(
allocated() ? realloc(m_buf.data.ptr, static_cast<size_t>(n))
: malloc(static_cast<size_t>(n)));
uint8_t* ptr =
static_cast<uint8_t*>(realloc(m_buf.data.ptr, static_cast<size_t>(n)));
if (!ptr) {
return DynIOBuffer::GrowResult::FailedOutOfMemory;
}
@@ -72112,12 +72105,6 @@ DynIOBuffer::grow(uint64_t min_incl) {
return DynIOBuffer::GrowResult::OK;
}
bool //
DynIOBuffer::allocated() {
IOBuffer buf = wuffs_base__empty_io_buffer();
return buf.data.ptr != m_buf.data.ptr;
}
// round_up rounds min_incl up, returning the smallest value x satisfying
// (min_incl <= x) and (x <= max_incl) and some other constraints. It returns 0
// if there is no such x.