Freeing all malloc()-created pointers with one command?-Collection of common programming errors

No, you can’t. There are various ways to sort-of accomplish this, but some of them encourage sloppy habits (for example, most runtimes on most OSs will release all the memory you allocated when your process exists, but this won’t help you during the execution of your program and usually won’t release shared resources that are not core memory).

One viable method is to use a pool allocator — there are plenty of resources on the topic if you ask Google about it. The concept is rather simple: you allocate (with malloc) one large pool of memory yourself at some start time, and then you manually suballocate (with your own hand-rolled function) from that pool, just returning pointers to blocks of the appropriate size that you keep track of yourself. Then you can free everything with one call to free that matches the original malloc call.

However, the reason to do this isn’t so that you can be lazy with your memory handling: you do this because of some performance-related reasons, usually, like providing superior locality of reference of small allocations or some such. If you want to do this just because you don’t want to think about remembering to release the resources you allocate, well… that’s not so great.

Other languages provide mechanisms (such as built-in garbage collectors, like C#, or RAII, like C++). But in C you generally need to be aware of your memory usage and manage it yourself, because there are fewer mechanisms to automate the cleanup for you.