tags:

views:

34

answers:

1

I have a structure that has a dynamic array in it. I have defined two of these structures.

I fill the array in the first structure, then use a line like

memcpy(R->v, A->v, A->n*sizeof(double)

where v is the array that has been dynamically allocated, and n is the number of entries.

R and A are the same type if that matters.

The problem is, the values are not being properyl copied into R. Any idea why? When I try to debug this in totalview, memcpy goes into a function called "very_huge_loop", but no exception or anything is thrown.

the array is approx 188k doubles in length.

Thanks

+1  A: 

It could be memory alignment. Some architectures do not like multi-byte values like double to start on any arbitrary byte address. When you allocate the array memory, you might want to use a function like memalign() instead of malloc(). If you are using new double[n] then it should already be aligned correctly.

Amardeep