Have you seen the snippet above?
It HeapReAlloc fails with HEAP_REALLOC_IN_PLACE_ONLY then you know there's not enough space to reallocate in place. In such case you can manually free the old memory chunk, and allocate a new one with the new size.