I am using a library that has a function that takes an array of structs. That struct and function has the following layout:
struct TwoInt32s { int32_t a;
malloc allocates bytes. Why did you choose "2*len" ?
You could simply use "sizeof":
int32_t *buffer = malloc(len * sizeof(TwoInt32s)); /* fill in the buffer */ write((struct TwoInt32s*)buffer, len);
and as Erik mentioned, it would be a good practice to pack the struct.