mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
1 parent
b900be0315
commit
8cfde80759
4 files changed
+33
-8
No files matched your search
@@ -26,6 +26,7 @@ The LICENSE has changed from a single license (Apache 2) to a dual license
|
|||||||
- Changed `lzw.set_literal_width` to `lzw.set_quirk`.
|
- Changed `lzw.set_literal_width` to `lzw.set_quirk`.
|
||||||
- Changed `set_quirk_enabled!(quirk: u32, enabled: bool)` to `set_quirk!(key:
|
- Changed `set_quirk_enabled!(quirk: u32, enabled: bool)` to `set_quirk!(key:
|
||||||
u32, value: u64) status`.
|
u32, value: u64) status`.
|
||||||
|
- Changed `wuffs_base__empty_foo` to return non-NULL ptr.
|
||||||
- Deprecate `std/lzw.decoder.flush`.
|
- Deprecate `std/lzw.decoder.flush`.
|
||||||
- Generated constants now default to unsigned.
|
- Generated constants now default to unsigned.
|
||||||
- Halve the sizeof `wuffs_foo__bar::unique_ptr`.
|
- Halve the sizeof `wuffs_foo__bar::unique_ptr`.
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ DynIOBuffer::DynIOBuffer(uint64_t max_incl)
|
|||||||
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
|
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
|
||||||
|
|
||||||
DynIOBuffer::~DynIOBuffer() {
|
DynIOBuffer::~DynIOBuffer() {
|
||||||
if (m_buf.data.ptr) {
|
if (allocated()) {
|
||||||
free(m_buf.data.ptr);
|
free(m_buf.data.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void //
|
void //
|
||||||
DynIOBuffer::drop() {
|
DynIOBuffer::drop() {
|
||||||
if (m_buf.data.ptr) {
|
if (allocated()) {
|
||||||
free(m_buf.data.ptr);
|
free(m_buf.data.ptr);
|
||||||
}
|
}
|
||||||
m_buf = wuffs_base__empty_io_buffer();
|
m_buf = wuffs_base__empty_io_buffer();
|
||||||
@@ -45,17 +45,27 @@ DynIOBuffer::grow(uint64_t min_incl) {
|
|||||||
return ((min_incl == 0) && (m_max_incl == 0))
|
return ((min_incl == 0) && (m_max_incl == 0))
|
||||||
? DynIOBuffer::GrowResult::OK
|
? DynIOBuffer::GrowResult::OK
|
||||||
: DynIOBuffer::GrowResult::FailedMaxInclExceeded;
|
: DynIOBuffer::GrowResult::FailedMaxInclExceeded;
|
||||||
|
} else if (n > SIZE_MAX) {
|
||||||
|
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
||||||
} else if (n > m_buf.data.len) {
|
} else if (n > m_buf.data.len) {
|
||||||
uint8_t* ptr = static_cast<uint8_t*>(realloc(m_buf.data.ptr, n));
|
uint8_t* ptr = static_cast<uint8_t*>(
|
||||||
|
allocated() ? realloc(m_buf.data.ptr, static_cast<size_t>(n))
|
||||||
|
: malloc(static_cast<size_t>(n)));
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
||||||
}
|
}
|
||||||
m_buf.data.ptr = ptr;
|
m_buf.data.ptr = ptr;
|
||||||
m_buf.data.len = n;
|
m_buf.data.len = static_cast<size_t>(n);
|
||||||
}
|
}
|
||||||
return DynIOBuffer::GrowResult::OK;
|
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
|
// 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
|
// (min_incl <= x) and (x <= max_incl) and some other constraints. It returns 0
|
||||||
// if there is no such x.
|
// if there is no such x.
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ class DynIOBuffer {
|
|||||||
DynIOBuffer(const DynIOBuffer&) = delete;
|
DynIOBuffer(const DynIOBuffer&) = delete;
|
||||||
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
|
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
|
||||||
|
|
||||||
|
bool allocated();
|
||||||
|
|
||||||
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
|
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13626,6 +13626,8 @@ class DynIOBuffer {
|
|||||||
DynIOBuffer(const DynIOBuffer&) = delete;
|
DynIOBuffer(const DynIOBuffer&) = delete;
|
||||||
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
|
DynIOBuffer& operator=(const DynIOBuffer&) = delete;
|
||||||
|
|
||||||
|
bool allocated();
|
||||||
|
|
||||||
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
|
static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64220,14 +64222,14 @@ DynIOBuffer::DynIOBuffer(uint64_t max_incl)
|
|||||||
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
|
: m_buf(wuffs_base__empty_io_buffer()), m_max_incl(max_incl) {}
|
||||||
|
|
||||||
DynIOBuffer::~DynIOBuffer() {
|
DynIOBuffer::~DynIOBuffer() {
|
||||||
if (m_buf.data.ptr) {
|
if (allocated()) {
|
||||||
free(m_buf.data.ptr);
|
free(m_buf.data.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void //
|
void //
|
||||||
DynIOBuffer::drop() {
|
DynIOBuffer::drop() {
|
||||||
if (m_buf.data.ptr) {
|
if (allocated()) {
|
||||||
free(m_buf.data.ptr);
|
free(m_buf.data.ptr);
|
||||||
}
|
}
|
||||||
m_buf = wuffs_base__empty_io_buffer();
|
m_buf = wuffs_base__empty_io_buffer();
|
||||||
@@ -64240,17 +64242,27 @@ DynIOBuffer::grow(uint64_t min_incl) {
|
|||||||
return ((min_incl == 0) && (m_max_incl == 0))
|
return ((min_incl == 0) && (m_max_incl == 0))
|
||||||
? DynIOBuffer::GrowResult::OK
|
? DynIOBuffer::GrowResult::OK
|
||||||
: DynIOBuffer::GrowResult::FailedMaxInclExceeded;
|
: DynIOBuffer::GrowResult::FailedMaxInclExceeded;
|
||||||
|
} else if (n > SIZE_MAX) {
|
||||||
|
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
||||||
} else if (n > m_buf.data.len) {
|
} else if (n > m_buf.data.len) {
|
||||||
uint8_t* ptr = static_cast<uint8_t*>(realloc(m_buf.data.ptr, n));
|
uint8_t* ptr = static_cast<uint8_t*>(
|
||||||
|
allocated() ? realloc(m_buf.data.ptr, static_cast<size_t>(n))
|
||||||
|
: malloc(static_cast<size_t>(n)));
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
return DynIOBuffer::GrowResult::FailedOutOfMemory;
|
||||||
}
|
}
|
||||||
m_buf.data.ptr = ptr;
|
m_buf.data.ptr = ptr;
|
||||||
m_buf.data.len = n;
|
m_buf.data.len = static_cast<size_t>(n);
|
||||||
}
|
}
|
||||||
return DynIOBuffer::GrowResult::OK;
|
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
|
// 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
|
// (min_incl <= x) and (x <= max_incl) and some other constraints. It returns 0
|
||||||
// if there is no such x.
|
// if there is no such x.
|
||||||
|
|||||||
Reference in new issue
Block a user