In UNIX systems we know malloc()
is a non-reentrant function (system call). Why is that?
Similarly, printf()
also is said to be non-reent
Let's understand what we mean by re-entrant. A re-entrant function can be invoked before a previous invocation has finished. This might happen if
malloc isn't re-entrant because it is managing several global data structures that track free memory blocks.
printf isn't re-entrant because it modifies a global variable i.e. the content of the FILE* stout.