Skip to content

coreinit: Return correct size from MEMResizeForMBlockExpHeap - #2022

Merged
Exzap merged 1 commit into
cemu-project:mainfrom
capitalistspz:blockresize
Aug 6, 2026
Merged

coreinit: Return correct size from MEMResizeForMBlockExpHeap #2022
Exzap merged 1 commit into
cemu-project:mainfrom
capitalistspz:blockresize

Conversation

@capitalistspz

Copy link
Copy Markdown
Contributor

When block size equalled the requested size, 0 was returned

@Crementif

Copy link
Copy Markdown
Member

Just in case we're not patching out an intentional replication of the real console, did you test this same thing on the Wii U?

But other then that, this seems very nice!

@capitalistspz

Copy link
Copy Markdown
Contributor Author

Just in case we're not patching out an intentional replication of the real console, did you test this same thing on the Wii U?

But other then that, this seems very nice!

I tested on the console and on Cemu with this program

#include <coreinit/memdefaultheap.h>
#include <coreinit/memexpheap.h>
#include <coreinit/memheap.h>
#include <whb/proc.h>
#include <coreinit/debug.h>
#include <cstddef>

static constinit std::byte ExpHeap[65536] = {};



int main()
{
    WHBProcInit();

    auto expHeap = MEMCreateExpHeapEx(ExpHeap, sizeof(ExpHeap), MEM_HEAP_FLAG_USE_LOCK);
    auto allocation = MEMAllocFromExpHeapEx(expHeap, 128, 128);

    auto const size = MEMGetSizeForMBlockExpHeap(allocation);
    OSReport("Allocation size is %d\n", size);
    auto resize = MEMResizeForMBlockExpHeap(expHeap, allocation, 128);
    OSReport("Resized to %d\n", resize);

    resize = MEMResizeForMBlockExpHeap(expHeap, allocation, 256);
    OSReport("Resized to %d\n", resize);
    while (WHBProcIsRunning()) {}

    MEMDestroyExpHeap(expHeap);

    WHBProcShutdown();

    return 0;
}

@Exzap

Exzap commented Aug 6, 2026

Copy link
Copy Markdown
Member

good catch, thanks

@Exzap
Exzap merged commit daacdda into cemu-project:main Aug 6, 2026
4 of 8 checks passed
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.

3 participants