News for hackers. Stuff that matters.
Re:Kirc – A tiny IRC client written in POSIX C99 by formerly_proven on Wednesday September 16, 2020 @03:06PM (#24496222)
On 64 bits malloc basically always succeeds, because you are very likely not running out of virtual memory. You can totally go ahead and malloc terabytes of RAM.

On 32 bits malloc is going to fail once your virtual memory space is full (~3 GB).

Error checking is somewhat redundant for most applications, since you're going to abort anyway, and if there are no pages available on access - well you're getting SIGSEGV anyway, just like you would accessing a null pointer (except on embedded devices). But beware of the exceptions. In C especially it's common to use null pointers as a flag... one of the reasons why new/delete in C++ is preferable; it throws and thus aborts when it fails, which you don't care to handle, so that's about perfect for a C++ exception.

There are no comments on this comment yet.