The code below returns an address when executed in Windows, though I was expecting it to return NULL.
int main()
{
char *ptr = NULL;
ptr = malloc(0);
printf("malloc returned = %u
", ptr);
}
What could have prompted such an implementation of malloc? Is there any reason behind it?
Since, this is a 0 byte memory, I didn't experiment writing any data. But, can this memory be used for anything at all?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…