summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/memory_manager_internal.h')
-rw-r--r--third_party/jpeg-xl/lib/jxl/memory_manager_internal.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h
index c728d62e35..e578e91f8e 100644
--- a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h
+++ b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h
@@ -36,11 +36,13 @@ static JXL_INLINE Status MemoryManagerInit(
} else {
memset(self, 0, sizeof(*self));
}
- if (!self->alloc != !self->free) {
+ bool is_default_alloc = (self->alloc == nullptr);
+ bool is_default_free = (self->free == nullptr);
+ if (is_default_alloc != is_default_free) {
return false;
}
- if (!self->alloc) self->alloc = jxl::MemoryManagerDefaultAlloc;
- if (!self->free) self->free = jxl::MemoryManagerDefaultFree;
+ if (is_default_alloc) self->alloc = jxl::MemoryManagerDefaultAlloc;
+ if (is_default_free) self->free = jxl::MemoryManagerDefaultFree;
return true;
}
@@ -52,7 +54,7 @@ static JXL_INLINE void* MemoryManagerAlloc(
static JXL_INLINE void MemoryManagerFree(const JxlMemoryManager* memory_manager,
void* address) {
- return memory_manager->free(memory_manager->opaque, address);
+ memory_manager->free(memory_manager->opaque, address);
}
// Helper class to be used as a deleter in a unique_ptr<T> call.