jsoncons icon indicating copy to clipboard operation
jsoncons copied to clipboard

fix: avoid over-allocating memory for 8 byte alignment or less

Open romange opened this issue 1 year ago • 1 comments

Fixes #509

romange avatar May 10 '24 05:05 romange

Thanks!

Line 147

if (reinterpret_cast<uintptr_t>(ptr) % align == 0)

will fail compilation if ptr is a "fancy pointer". I don't have a test case for that, but you'll see it if you try to compile boost_examples/interprocess_allocator/shared_memory.cpp. I think you need to write it as

q = extension_traits::to_plain_pointer(ptr);
if (reinterpret_cast<uintptr_t>(q) % align == 0) {

Line 157

align_pad = (align-1);

requires a cast to suppress a warning.

danielaparker avatar May 14 '24 00:05 danielaparker

@danielaparker PTAL

romange avatar May 16 '24 07:05 romange

Thanks for contributing

danielaparker avatar May 20 '24 02:05 danielaparker