In my experience, programs rarely have one exit point. Meaning:
malloc needed varibles
code
free variables.
exit to command line.
Functions can be this simple. Main-line code rarely is this simple.
If you add checking for errors of various kinds:
filename missing, file wonât read or write, wonât open or close.
maloc variables
check open file successful, if error exit
check read file, if error exit.
check write file, if error exit
close file, if error exit.
free variables.
Thatâs four exit points before the memory is freed. Iâve had to write the code so it flows into the exit at the end. Thatâs is NOT simple. Else, create a function to free all the variables at each exit point.
Add up all the exits points in something as complex as scanvirus as c code. This makes for a very complex structure.
PS, I can do linked lists of various types. I choose not to use them for simplicity.
Iâve used the function âsizeof(variable)â for memory allocation.
Sorry, but I do not understand you here at all. What e.g. is a âshortcut bash commandâ. And what is a âsystem commandâ.
I get the idea that we are going off post. My first answer here had to purposes:
to point to the fact that we all use âlingoâ in ICT, specially here in discussing shell features. Most of these lingo words have a meaning that is defined in e.g. the man page of the shell. One should use those terms in the meaning that is defined in this context, else you will have confusion at all sites;
speclaly in this case, the difference if it is a shell-builtin or a separate tool/program/binary is for you the difference of where to find the coding that you may want to use again in your own program. But that went completely wrong. Instead of saying: âaha, better look in the source-code of tee then in the source code of bashâ, you stated that it is all one same bunch of words and that those that lay value in making a difference between a program, an alias, or a builtin are just pedantic for the case of being pedantic.
Oh dear, the âspaghetti codeâ versus âstructured codeâ discussion:
Yes, C doesnât have the concept of âconstructorsâ and âdestructorsâ â as C++ does âŚ
Yes, C is rather similar to assembler in that, one has to ensure that one cleans up before one exits âŚ
Thereâs no clear answer to this issue â itâs purely a matter of taste and, personal preferences and, personal abilities and, the capabilities of the tools being used âŚ