How to write a structure with a fixed size array (allocated dynamically) to a packet table then how to read it back


I would like to create a Packet Table (FL) with following datatype:

int size = 128;
typedef struct MyStruct {
long long date;
int len;
unsigned short *buffer;
} MyStruct;

MyStruct s1; // structure for writting
MyStruct s2; // structure for reading = 12345678912;
s1.len = size;
s1.buffer = (unsigned short*)malloc(size*sizeof(unsigned short));
for (n = 0; n < size; n++)
s1.buffer[n] = (unsigned short) n + 1;

How to write this structure to packet table fixed length?
Then how to read data back from the packet table into the s2 structure?

Thanks for your help!

Vincent Herrero