This should be safer.

In Windows, when you allocate a piece of memory, system will give you a
little more to align. Usually you can just use them(they are zeroed
already) and the function like HeapSize will return the correct size
instead of your input. But if the size of data can be divided by
4(depends on your cpu), there won't be any extra space.