Well, this is about nice code to look at, not avoiding delaying the ship date.
Moreover, here's approximately how I'd write that TGA loading function:
1. Write a function to load just a header.
2. Unit test the function with a header.
3. Write a function to do the RLE decoding.
4. Unit test the function with some data.
5. etc.
6. Start assembling the pieces.
7. Unit test the whole thing.
Meanwhile, you tried to write it all in one monolithic function, and so now you're testing the whole thing (hopefully with a unit test) and you're staring at the debugger (or worse, some printf output) wondering what little mistake you made. Maybe if you're brilliant, like Carmack, you beat me to the finish line. But most of us are mere mortals.
Moreover, here's approximately how I'd write that TGA loading function:
1. Write a function to load just a header. 2. Unit test the function with a header. 3. Write a function to do the RLE decoding. 4. Unit test the function with some data. 5. etc. 6. Start assembling the pieces. 7. Unit test the whole thing.
Meanwhile, you tried to write it all in one monolithic function, and so now you're testing the whole thing (hopefully with a unit test) and you're staring at the debugger (or worse, some printf output) wondering what little mistake you made. Maybe if you're brilliant, like Carmack, you beat me to the finish line. But most of us are mere mortals.