Problem: My data is not moved to the new memory block created by realloc(). As I read my streaming data from a file or serial port. I want to store a part of the data in a dynamic array of doubles, to be graphed on a strip chart real time. When I use realloc() to increase the size by one "double", to make room for the next data item, the array size is increased, but the old data is not moved to the new block of memory, and is lost !
Since I dont know the number of doubles that are to be read, I want to use realloc() to increase the size as I get new data. My solution was to copy the data to a temporary malloc() array, then use realloc() to increase the size, then copy the data back. I sho
uld not have to do this. should I ? Realloc() should move the existing data in the array to the new block of memory, and give me room for my new data ?