Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CVar system] Memory leak inside the code example + typo inside the article #80

Open
Vin789 opened this issue Nov 7, 2022 · 0 comments

Comments

@Vin789
Copy link

Vin789 commented Nov 7, 2022

Hi !

First, thx a lot for all your articles and code examples they are really useful. I'm integrating a CVar system based on your example inside my own engine and I think I found a trivial memory leak inside the example code here:

https://github.com/vblanco20-1/vulkan-guide/blob/engine/extra-engine/cvars.cpp

Line 49 you are doing a dynamic allocation for the CVarStorage array but you never delete this array inside the code. Adding:

~CVarArray()
{
	delete[] cvars;
	cvars = nullptr;
}

Right after the constructor should fix the issue if ever you want to fix it.

Also inside the article:

//checkbox CVAR
AutoCVar_Int CVAR_TestCheckbox("test.checkbox", "just a checkbox", 0, CVarFlags::EditCheckbox);

//int CVAR
AutoCVar_Int CVAR_TestInt("test.int", "just a configurable int", 42);

//float CVAR
AutoCVar_Int CVAR_TestFloat("test.float", "just a configurable float", 13.37);

//string CVAR
AutoCVar_String CVAR_TestString("test.string", "just a configurable string", "just a configurable string");

There is a small typo for the float CVar example. It Should use AutoCVar_Float instead of AutoCVar_Int (it won't compile anyway as the last argument is a double and not an int). Again it's trivial if ever you want to fix it.

Thx again for all the resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant