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

Fix indexing for platforms where char size is larger than a byte #72

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

Conversation

GMMan
Copy link

@GMMan GMMan commented Mar 30, 2022

On platforms where the minimum memory access size is larger than a byte (case in point, μ'nSP where each address refers to one 16-bit word rather than a byte), indexing would never work due to the index buffer being initialized improperly. Instead of each element being initialized to -1 as would typically happen on a system with byte sized access, it gets initialized to 255. This breaks the indexing logic and causes it to go into an infinite loop.

This patch changes the initializer from 0xff to -1, so depending on the platform it should always initialize the entire array with -1. On byte access systems, memset() will truncate the -1 to 0xff as per standard, which results in the same desired behavior.

@silentbicycle
Copy link
Collaborator

Thanks, this will be cherry-picked to the develop branch for the next versioned release.

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