Okay, as I added some printf() statements to see where it was crashed out and it appears to be when I'm calling destroy_sprite()...I think. Because that's the only call to free() after the game loop finishes.
Code:
*** glibc detected *** ./gameloop: free(): invalid next size (fast): 0x088f9530 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb74beee2]
./gameloop[0x804921e]
./gameloop[0x8049eda]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb74624d3]
./gameloop[0x8049111]
Is my destroy_sprite() code wrong? What does "free(): invalid next size" mean in this context?
EDIT: I've definitely narrowed it down to the "free(s);" call in destroy_sprite(). If I take out that, I still get a segfault/core dump but I don't see what I'm doing wrong. Every call to malloc() needs a corresponding free(). So if I leave it in, I get the backtrace above. If I take it out (memory leak) I get a core dump.