I am working on some code and the original coder had a fetish with the assert macro. I mean it is everywhere. Seems he substituted assert() for if statements. Anyways my question is this, seeing as how assert() calls abort(), wouldn't that be cause for memory leaks if memory has been allocated elsewhere in the program? I think it will cause that memory is never freed, which leads into my next question, Should assert() be used this frequently? I mean it isnt uncommon for this program to contain 20 or more assert's in a single function. This is my first real programming job so to speak (I am working for free to get experience) but this many asserts just doesn't seem right.
I want to change most of these asserts to if statements so that the functions return a value on success or failure and clean up after themselves not just terminate the program. Would this be the correct way to handle things?
Any help is appreciated