←back to thread

48 points ingve | 1 comments | | HN request time: 0.22s | source
Show context
randomNumber7 ◴[] No.44390120[source]
I never had the use case to allocate 0 bytes of memory.

If I would allocate 0 bytes of memory and get a pointer to it, I wouldn't care what the value of the pointer is since I am not allowed to dereference it anyways.

But then again, why would I allocate 0 bytes of memory?

replies(1): >>44392685 #
1. bobmcnamara ◴[] No.44392685[source]
Sometimes it shakes out simpler for a generic container.

Ex: a vector using only a counter and pointer - you can use realloc() with fewer pointer validity checks.