Archie Gertsman
Archie Gertsman

Reputation: 1661

SDL struct Objects - Set to nullptr After Calling Destroy Function?

Say I have an SDL_Window object, SDL_Window *window. Once I'm finished using it, I call SDL_DestroyWindow(window) to destroy it. Should I then say window = nullptr or does the destroy function take care of that? I have seen some code set it to nullptr, and other code not. Thanks.

Upvotes: 0

Views: 225

Answers (1)

user6499716
user6499716

Reputation:

When you deallocate memory using free() or delete the pointer will keep its value. So I guess it's the same for SDL_DestroyWindow().

Setting your pointer to nullptr won't be necessary since you are not supposed to use memory you just freed. But if you feel comfortable setting it to nullptr I won't stop you.

Upvotes: 1

Related Questions