Is there any way to create dynamically resizable arrays with win32 API?

My problem is this, I have one loop which in every cycle takes
some data and saves it in memory for further processing.
Now, I the size of data is fixed and known, but I dont know
the number of times loop will execute, so I dont know how many
memory I am going to need.
I tried with linked lists but later working on processing of that
required a lot of complicated code which I couldnt make to work.

Ideally I would like that in every loop cycle memory of fixed size is allocated
and appended on previous

Eg.

After 1st loop cycle
------------------------
|....size of data......|
------------------------
^
|
+--------- start of array


After 2nd loop cycle
-----------------------------------------------
|....size of data......|....size of data......|
-----------------------------------------------
^
|
+--------- start of array (eg. 0x100000)

After 3rd loop cycle
---------------------------------------------------------------------
|....size of data......|....size of data......|......size of data...|
---------------------------------------------------------------------
^
|
+--------- start of array (eg. 0x100000)


Is this anyhow possible?
If not, what are other ways of dynamic memory allocation, when you dont know
how much memory you will need (except linked lists) ?
Posted on 2003-06-29 19:12:31 by Mikky
HeapAlloc, HeapRealloc, HeapFree ?

The HeapReAlloc function reallocates a block of memory from a heap. This function enables you to resize a memory block and change other memory block properties. The allocated memory is not movable.

sounds like it might do what you need

GetProcessHeap, HeapAlloc, HeapCreate, HeapDestroy, HeapFree, HeapSize
Posted on 2003-06-29 20:12:43 by evlncrn8
A linked list is one of the easiest data structures to work with. Give it another try.
Posted on 2003-06-30 02:45:44 by iblis
Posted on 2003-06-30 05:40:34 by Vortex
hay evlncrn8, I didnt know that those API's can do that, so far I only used GlobalAlloc/Lock combination, thanks for the tip:alright:

iblis, linked lists are ok but in my case code just becomes too complicated
Posted on 2003-06-30 08:45:08 by Mikky
linked list is pretty easy, but heapalloc/realloc could do the trick here - as long as you don't do any other memory allocations inbetween, as you'd end up with a pretty fragmented heap.
Posted on 2003-07-01 04:50:24 by f0dder