5 ms·
Because then the caller needs to treat it differently from non-empty buffers.
by repiret 2mo ago
Because then the caller needs to treat it differently from non-empty buffers.
- kazinator 2mo agoNo, it doesn't. It calls: void buffer_free(void *buf) { if (buf != null_buffer_singleton) free(buf); }
- Joker_vD 2mo ago...which treats it differently from non-empty buffers :) But frankly, having a 1-byte buffer, pointer to which can serve as a sentinel value à la NULL (but dereferenceable!), and which you can pass to free() without it being deallocated is indeed rather useful.