Minor, but instead of looping and reading every string, consider stat or fstat with the file handle. The OS will populate a struct stat. The member you need is st_size. You'll have to think about the tradeoff of st_size representing every byte on disk (carriage return/newline) while your approach might generate slightly smaller allocations. Reading it and then immediately copying it can be pretty harsh on the data cache and the block I/O systems; This could be mad faster still by using mmap() (Windows calls it something else, but it's there on all the UNIX-y systems) and just parsing the data in place via pointer.
https://github.com/nanochess/pretty6502/blob/192644256c104e5eee72d7c2e98bfff19629dcab/pretty6502.c#L209
Minor, but instead of looping and reading every string, consider stat or fstat with the file handle. The OS will populate a struct stat. The member you need is st_size. You'll have to think about the tradeoff of st_size representing every byte on disk (carriage return/newline) while your approach might generate slightly smaller allocations. Reading it and then immediately copying it can be pretty harsh on the data cache and the block I/O systems; This could be mad faster still by using mmap() (Windows calls it something else, but it's there on all the UNIX-y systems) and just parsing the data in place via pointer.
Just a tip...