Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
adrianN
· 3y ago · 0 comments
How would malloc/free be better in that situation?
Comments
[–]
ihatepython
3y ago
I don't know, but when I use C, I like to statically allocate everything if at all possible, I don't free() anything, I let the OS clean everything up at exit(). A lot of the small Unix utilities don't necessarily need dynamic memory allocation IMO
[–]
adrianN
OP
3y ago
That's a good strategy in C++ too. Check the MISRA guidelines for example.
[–]
stevenhuang
3y ago
I'm not saying it's better, it wouldn't. Parent was asking in what scenarios can custom destructor causes issue so I just provided one.
[–]
torstenvl
3y ago
malloc/free are better because free(window) could never call free(window->widget->font)