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

stb_truetype: Fixed a memory leak in example code #758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Brotcrunsher
Copy link
Contributor

The example code previously created a bitmap via stbtt_GetCodepointBitmap but never freed it, effectively creating a memory leak. This commit calls the proper stbtt free function stbtt_FreeBitmap.

The example code previously created a bitmap via `stbtt_GetCodepointBitmap` but never freed it, effectively creating a memory leak. This commit calls the proper stbtt free function `stbtt_FreeBitmap`.
@Brotcrunsher Brotcrunsher changed the title Fixed a memory leak in example code stb_truetype: Fixed a memory leak in example code Apr 30, 2019
@Brotcrunsher
Copy link
Contributor Author

As a side note: The example also never calls fclose to the corresponding fopen. This however could be seen as an irrelevant best practice thing which has nothing to do with the topic of the example code: showing stb_truetype.

@nothings
Copy link
Owner

Yes, the sample code didn't do any cleanup of anything, which was consistent. It also doesn't do any error checking. I thought it was clearly supposed to be throw-away sample code, not cut-and-paste-able sample code, but clearly I was wrong, so I need to rethink this.

@Brotcrunsher
Copy link
Contributor Author

I volunteer to do this for stb_truetype. If you want this, just name me the scope of the checks:

1.) Should memory leaks be checked?
2.) Should return values be checked?
3.) Should C library functions be handled properly?
4.) Anything else that I miss?

@nothings
Copy link
Owner

nothings commented Jul 13, 2020

@Brotcrunsher :

I volunteer to do this for stb_truetype. If you want this, just name me the scope of the checks:

1.) Should memory leaks be checked?
2.) Should return values be checked?
3.) Should C library functions be handled properly?
4.) Anything else that I miss?

I appreciate the volunteering, but since the sample code is embedded in the library I need to trade off all of these choices with length, so I have to do it myself I think.

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

Successfully merging this pull request may close these issues.

2 participants