Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

assert ( malloc...

Name: Anonymous 2010-06-28 13:36

A question for you, Anon.

If you watch at malloc() manpage you can notice that the function may return NULL in some cases (i.e. errors or 0-sized allocation). How do you face this issue?

I noticed that many programmers check the return value and manage error routines for it, while other just assert() the return value not to be NULL.

Also in C++ by the way you use the new operator without taking care about the return value (I guess it's asserted to be not NULL under the hood, is it?)

What is your opinion?

Name: Anonymous 2010-07-02 8:40

>>60
VLAs don't have to be on the stack. You don't even need a stack at all to implement C.
Uh? >>57 did not say anything about a stack. >>58 mentions the stack, and says nothing about VLAs. Are you confused?

Also, your blatant Perl plug is ludicrous. alloca() is useful for performance. When you just need a scratch buffer, malloc() is by comparison extremely slow, leads to memory fragmentation, and will give you space in a different cache line. alloca() is compiled into a single processor instruction to offer you the space you need, and the space is (likely) already in the processor cache.

In fact absolutely everything in your post is wrong. Hand in your geek card; no internets for you today.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List