I want to convert this piece of code using this memory layout transformation : https://software.intel.com/en-us/articles/memory-layout-transformations (Array of Structures to Structure of Arrays)
Here are the codes before and after applying the transformation and I want to know whether I'm doing it right or not?
Before:
typedef struct {
double x;
}str1;
typedef struct {
str1 v;
}str2;
int main(){
str2 *pointer;
double y = pointer[1].v.x;
return 0;
}
After:
typedef struct {
double x[1];
}str1;
typedef struct {
str1 v;
}str2;
int main(){
str2 pointer;
double y = pointer.v.x[1];
return 0;
}