The way it's usually done is something like this:
Read Len from whatever you're reading from
Allocate a buffer of size Len + sizeof Len bytes.
Copy Len into the first sizeof Len bytes of the buffer
Read Len bytes into the buffer after the copied value of Len
Cast the buffer pointer to FRAME* and return it
Let's presume you're reading from a C FILE:
FRAME* ReadFRAME(FILE* file)
{
int Len;
fread((void*)&Len, sizeof(Len), 1, file);
char* space = (char*)malloc(Len + sizeof(Len));
FRAME* gotFrame = (FRAME*)space;
gotFrame->Len = Len;
fread((void*)gotFrame->Text, 1, Len, file);
return gotFrame;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p