tim wrote: > > Requesting zero bytes returns a non-NULL pointer. > > I can't guarantee this without insane effort, and our code has never > guaranteed this. umm. I have to admit that it's rather ugly, but I'm pretty sure the following guarantees that requesting zero bytes will never return a NULL pointer: static char nullbyte = MAGIC; void* malloc(int bytes) { if (bytes == 0) { #if DEBUG_MODE if (*nullbyte != MAGIC) uh-oh #endif return &nullbyte; } ... void free(void* ptr) { if (ptr == &nullbyte) { #if DEBUG_MODE if (*nullbyte != MAGIC) uh-oh #endif return; /* nothing to do */ } ... </F>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4