refactor(memory): update mem_reallocate to copy optional interface #1518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update:
The mem_reallocate interface has been updated to include an optional copy argument. It has been refactored to copy by default, however, this can be overriden with the optional arg. The interface will now throw an error if the array size has shrunk and copy is set to TRUE. The mem_reset interface has been removed.
The MemoryManager mem_reallocate interface for the most part assumes a size increasing reallocation and then copies existing array values into the new array. This new interface is meant to reallocate to any size (including 0) and to never copy existing values. The existing mem_reallocate interface could probably be updated to alternatively provide this same behavior so this PR represents one way forward.
This is needed by IDM when Dynamic list based array data is loaded across periods that do not have an explicit dimension- TVK and TVS are examples. In these cases, maxbound implicitly is the number of reduced nodes, however to reduce memory overhead it might preferred to reallocate these arrays to the size needed for each period. This interface supports the idea of resetting allocated memory from the previous period.