Hacker News new | ask | show | jobs
by orbifold 3038 days ago
Malloc does not fail under Linux unless you are in very peculiar circumstances.
2 comments

Not everyone is running Linux.

And anyway, it is dirty - like crossing the street without looking for cars because traffic around here is very mellow, or peeing without washing your hands afterwards.

(That being said, I once helped somebody to write a program whose task it was to deliberately get the host system to the point where malloc(3) failed. It was not as trivial as one might think.)

Malloc will still fail for overly large allocation sizes. If you try to malloc(-1), for example.