Why does malloc initialize the values to 0 in gcc?

前端 未结 9 1972
慢半拍i
慢半拍i 2020-11-22 16:34

Maybe it is different from platform to platform, but

when I compile using gcc and run the code below, I get 0 every time in my ubuntu 11.10.

#include         


        
9条回答
  •  臣服心动
    2020-11-22 16:55

    From gnu.org:

    Very large blocks (much larger than a page) are allocated with mmap (anonymous or via /dev/zero) by this implementation.

提交回复
热议问题