You could make your life a little easier by using a container that takes care of its own size if you don't want to have to read the size and allocate the correct memory yourself.
Yeah but in this case I need to keep an 4 bytes dword (for memory pointer) more in every file structure and maybe even more 4 (for saving the allocated memory size by malloc()). Let's thought I have 200 objects with a variadic struct and the result is : 1600 ( 200*8 ) bytes more than that in the file struct.
Not by I reverse engineering a program which has a char string with the file inside it and and the data there are used by the program directly. When I use an allocated memory the file string will be split into small parts. I want to know a approach that have the same behavior like this program.
EDIT: Anyway I found a way placing the structure to point in the char string.