I have heard that it's good practice to check if malloc/realloc/calloc operation was successful. Wondering what are the cases/corner cases where it will fail, and how common these cases could be.
Asked
Active
Viewed 24 times
0
-
Running out of memory would be the obvious one. – Jörg W Mittag Apr 24 '21 at 08:47
-
1It is not good practice to check whether memory allocation functions were successful. It is good practice to check for *all possible error conditions*. – Cheatah Apr 24 '21 at 10:34