Hacker News new | ask | show | jobs
by EGreg 3536 days ago
So that's easy:

  #define NEW(t, args...) ((t*)malloc(sizeof(t)) && t ## _construct(args))

  #define DELETE(t) (t ## _destruct() && !free(t) && (t = NULL))
2 comments

This isn't sufficient unless you consciously error-check and goto-trap every single failure point in your code. Which you might do. But you'd be the literal one percent. If not the literal one permille.
In DELETE(), is t the variable name or the type name? It is used as both, which won't work.