cgen: fix iterate's "ptr + len" when ptr is NULL

Updates #135
This commit is contained in:
Nigel Tao committed 2024-04-05 13:47:25 +11:00
1 parent 8ed5d1327b
commit 2142aa65fc
3 files changed
+88 -66

No files matched your search

+11
View File
@@ -190,6 +190,17 @@ wuffs_private_impl__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
// ---------------- Slices and Tables
// This function basically returns (ptr + len), except that that expression is
// Undefined Behavior in C (but not C++) when ptr is NULL, even if len is zero.
//
// Precondition: (ptr != NULL) || (len == 0).
static inline const uint8_t* //
wuffs_private_impl__ptr_u8_plus_len(const uint8_t* ptr, size_t len) {
return ptr ? (ptr + len) : NULL;
}
// --------
// wuffs_private_impl__slice_u8__prefix returns up to the first up_to bytes of
// s.
static inline wuffs_base__slice_u8 //