←back to thread

49 points ingve | 2 comments | | HN request time: 0.61s | source
1. 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 #
2. 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.