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

A possible bug has been discovered #8

Closed
JimmyLuoX opened this issue Aug 22, 2024 · 1 comment
Closed

A possible bug has been discovered #8

JimmyLuoX opened this issue Aug 22, 2024 · 1 comment

Comments

@JimmyLuoX
Copy link

In the function vlan_find_or_add_room, in the case of case 0, we insert a new meta data. Shouldn't we insert from the end to the beginning?"
original code:

case 0: // merge none
// insert into meta list
arr->nummeta++;
arr->meta = realloc(arr->meta, arr->nummeta * sizeof(*arr->meta));
assert(arr->meta);
for (uint16_t i = succ; i < arr->nummeta - 1; i++)
 arr->meta[i+1] = arr->meta[i];
arr->meta[succ].offset = startoffset;
arr->meta[succ].start = vid / 16;
return succ;

The code should be changed to

for (uint16_t i = arr->nummeta - 1; i > succ; i--) {
    arr->meta[i] = arr->meta[i - 1];
}
@michael-dev
Copy link
Owner

michael-dev commented Aug 26, 2024

I think you're right. The current look would just keep copying arr->meta[succ] during all iterations.

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

No branches or pull requests

2 participants