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

Some optimizations on image.c buffer and stb_image to use less memory. #422

Merged
merged 1 commit into from
Sep 2, 2019

Conversation

lucasbrg
Copy link
Contributor

@lucasbrg lucasbrg commented Sep 1, 2019

Now it is possible to load some larger png, but still have some limitations.

When stb_image runs out of allocated memory, it asks to reallocate the double it had before. It quickly runs out when loading larger files. Changed it to realloc a fixed amount, saving some memory in the process.

Made some changes to image.c realloc to just append data in case the pointer being reallocated is the same as the last one allocated (as it is most of the times when loading images).

It also prevents some crashes by avoiding memcpy in case there is no more memory available.

Kind of related to #407 and #408, but didn't solve the problem completely.

@RobDangerous RobDangerous merged commit 5d6d9e5 into Kode:master Sep 2, 2019
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

Successfully merging this pull request may close these issues.

2 participants