Take a look at this sectionCode.
P = Malloc (bytes );
If (P = Null)
... {
Printf ("Can't allocate enough memory.");
Return 0;
}
On the surface, this is very good, considering the insufficient memory allocation is an error. But there is a problem: imagine that when it takes several hours to process a document, your favorite text processing period suddenly tries to allocate 20 or 30 bytes to a new font instance, the result allocation fails, and an explanation is written to stdout, and the processing is terminated. I have no chance to cancel the operation that causes the memory allocation request. I have no choice to save my work. I have been working for an hour.
This is an example in the Standard C language book. Maybe with the virtual memory technology, we don't have to worry about the memory insufficiency error when applying for a new memory. So such judgment will never be executed.ProgramCan run, get the correct result. So we think there is no problem. But in the face of other exceptions, do we have to deal with them in the same wrong way. For example, if an error occurs, you can immediately exit the program, and at most, you will be prompted about the error. But have we considered the problem from the user's perspective? What should we do with the data they are processing? This mindset is sometimes terrible.