3 ms·
If you have something which contains pointers, you should have a destructor function for it, which itself should check if the pointer is not NULL before attempt
by Arch-TK 8mo ago
If you have something which contains pointers, you should have a destructor function for it, which itself should check if the pointer is not NULL before attempting to free any fields.
- t43562 8mo agoThat's certainly one way to do it if you're writing all the code.
- Arch-TK 8mo agoIf you have something which doesn't come with such a function, nothing stops you writing it?
- 1718627440 8mo agoWe are talking about C. A destructor function in C is a function that gets called when the library gets unloaded. No you shouldn't have a destructor function for it.
- Arch-TK 8mo agoThe C language has no such concept of attribute destructor and I am not talking about attribute destructor. I just mean, in the simple English sense, a function which exists to deallocate a structure.