From 07f0cba388cf6690e67d9ffaa3dc3f82281ed38f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Oct 2025 15:23:05 -0600 Subject: [PATCH] [alloc-pool] Fix MSVC warning Fixes https://github.com/harfbuzz/harfbuzz/issues/5613 --- src/hb-alloc-pool.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-alloc-pool.hh b/src/hb-alloc-pool.hh index 77d0e03f7..effea78eb 100644 --- a/src/hb-alloc-pool.hh +++ b/src/hb-alloc-pool.hh @@ -67,7 +67,7 @@ struct hb_alloc_pool_t return ret; } - unsigned pad = (unsigned)(-(uintptr_t) current_chunk.arrayZ) & (alignment - 1); + unsigned pad = (unsigned) ((alignment - ((uintptr_t) current_chunk.arrayZ & (alignment - 1))) & (alignment - 1)); // Small chunk, allocate from the last chunk. if (current_chunk.length < pad + size) @@ -77,7 +77,7 @@ struct hb_alloc_pool_t hb_vector_t &chunk = chunks.arrayZ[chunks.length - 1]; if (unlikely (!chunk.resize (ChunkSize))) return nullptr; current_chunk = chunk; - pad = (unsigned)(-(uintptr_t) current_chunk.arrayZ) & (alignment - 1); + pad = (unsigned) ((alignment - ((uintptr_t) current_chunk.arrayZ & (alignment - 1))) & (alignment - 1)); } current_chunk += pad;