Hacker News new | ask | show | jobs
by randyrand 307 days ago
IMO error objects should’ve included a pointer to some extra preallocated memory.

In my C code I always allocate my error objects first, with usually 1024 bytes just for error strings.

In cases where i don’t care for error strings, i allocate 0 bytes for them.

I have a simple function to append error strings, and it checks for space. So all the code is ambivalent about whether this extra space exists.

works wonderfully.