What's the point of malloc(0)?

后端 未结 17 1836
庸人自扰
庸人自扰 2020-11-22 15:40

I just saw this code:

artist = (char *) malloc(0);

...and I was wondering why would one do this?

17条回答
  •  清歌不尽
    2020-11-22 15:58

    Not sure, according to some random malloc source code I found, an input of 0 results in a return value of NULL. So it's a crazy way of setting the artist pointer to NULL.

    http://www.raspberryginger.com/jbailey/minix/html/lib_2ansi_2malloc_8c-source.html

提交回复
热议问题