Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Dynamic Memory Allocation

gelarimer
Beginner
657 Views
I have a List View control (report view)in a win32 program, and would like to create memory for the data in theList View control as the user adds items (or data rows). The user addsitems as he works with the program, so therewill be no way to predetermine the memory required.
Is there a way to incrementally allocate an array?
Thanks for any info.
0 Kudos
4 Replies
Steven_L_Intel1
Employee
657 Views
Not really, but you can use the new MOVE_ALLOC intrinsic to implement a "reallocate" without copying the data twice.
0 Kudos
gelarimer
Beginner
657 Views

I am using vs. 8.1... of IVF so I assume that the MOVE_ALLOC is in vs. 9.... From your post itsounds like this intinsic can be used to increase the size of an allocatable array without loosing data in the array. Is this correct?

Thanks.

0 Kudos
Steven_L_Intel1
Employee
657 Views
Not exactly.

Without MOVE_ALLOC you have to do what you want this way:

1. Allocate temporary array the same size as the old one.
2. Copy data from old array to temp
3. Deallocate old array
4. Allocate new array to new size
5. Copy data from temp
6. Deallocate temp

With MOVE_ALLOC you do this:

1. Allocate a temp array with the new size
2. Copy data from old to temp
3. Call MOVE_ALLOC (old,temp)

This causes the old array to be deallocated, the storage for the temp now belongs to the "old" array, and the temp array has the status unallocated.

MOVE_ALLOC is a 9.0 feature (in an update as of a few months ago.)
0 Kudos
gelarimer
Beginner
657 Views
Thanks for the info.
0 Kudos
Reply