I have records with flexible array member
typedef struct record {
    unsigned foo;
    signed bar;
    double number[];
} record;
I have multiple records with the same amount of numbers so I can arrange them in array. I would like to allocate them into one continuous memory space.
const unsigned numbers = ...;
const unsigned records = ...;
const size_t record_size = sizeof(record) + numbers*sizeof(double);
record *prec = malloc(records*record_size);
So now I know record_size and I can access it but what is best practice how to do it correctly and safely by given record index?
I can do it when I would separate header containing foo and bar and numbers, but I would like to keep record together for cache coherency.
 
     
    