When Things Go Wrong: Error Handling Strategies in C

Post 6 of the Dynamic Arrays in C series · Full source code on GitHub The Error You’ve Been Ignoring Every function we’ve written so far can fail. array_create calls malloc, twice. array_push calls realloc when the buffer is full. Every one of those calls can return NULL, and every time it does, we’ve printed a message to stderr and returned -1 or NULL. That’s the extent of our error handling: we report the problem and hope the caller notices. ...

June 11, 2026 · 18 min · pablo