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

Remove gDecompressionBuffer #6029

Merged
merged 14 commits into from
Jan 23, 2025

Conversation

DizzyEggg
Copy link
Collaborator

@DizzyEggg DizzyEggg commented Jan 15, 2025

If someone's already started working on it, or would like to do it - let me know and I'll cancel the PR.

If not, I'll continue working on it.

Things to note in the release changelog:

  • gDecompressionBuffer has been removed. Use either malloc_and_decompress or Alloc, then Free on the pointer when you're done. Whatever fits your use-case the best.
  • See the PR for examples of how to use those functions.

@DizzyEggg
Copy link
Collaborator Author

It is done. gMemeBuffer has been utterly destroyed. The last remnants of it are hidden, buried deeply behind comment blocks.

EWRAM gains:

EWRAM:      243440 B       256 KB     92.86%
EWRAM:      227056 B       256 KB     86.61%

Because GF abused the buffer, this PR affects pretty much every area of the game(though some are more affected than others), so a full playthrough would be advised before merging.
I'm mostly worried about memory leaks, despite being extra cautious with allocating and freeing memory.
I'm also not sure about link features, including link contests, union room and mystery gift/event things. So I'd be grateful if someone checked these areas as well.

@DizzyEggg DizzyEggg marked this pull request as ready for review January 17, 2025 11:07
@DizzyEggg DizzyEggg changed the title Remove gDecompressionBuffer (WIP) Remove gDecompressionBuffer Jan 17, 2025
@hedara90
Copy link
Collaborator

hedara90 commented Jan 17, 2025

Trading: Works.
Link Battles: Works.
Link Contests: Works.
Mugshots: Works.
Berry Blending: Works, a lot in a row, doesn't seem to leak.

@AsparagusEduardo AsparagusEduardo added the type: big feature A feature with big diffs and / or high impact / subjectivity / pervasiveness label Jan 17, 2025
Copy link
Collaborator

@hedara90 hedara90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had time to look through it properly.
Some initial things.

include/decompress.h Show resolved Hide resolved
include/decompress.h Show resolved Hide resolved
@@ -255,10 +255,14 @@ static void CB2_MysteryEventMenu(void)
case 11:
if (gReceivedRemoteLinkPlayers == 0)
{
// No clue what is going on here, and from where gDecompressionBuffer gets actually populated with mystery event script.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there even a way to test mystery gifts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no idea. If there is, we should test them.

src/ereader_screen.c Show resolved Hide resolved
Copy link
Collaborator

@hedara90 hedara90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should allocations with 0xXXXX sizes have #defined sizes instead?

src/berry_blender.c Outdated Show resolved Hide resolved
src/decompress.c Outdated Show resolved Hide resolved
src/link.c Show resolved Hide resolved
src/pokenav_main_menu.c Outdated Show resolved Hide resolved
src/pokenav_main_menu.c Outdated Show resolved Hide resolved
@DizzyEggg
Copy link
Collaborator Author

Review comments applied @hedara90

@hedara90 hedara90 merged commit 4e0eab9 into rh-hideout:upcoming Jan 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: big feature A feature with big diffs and / or high impact / subjectivity / pervasiveness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants