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

Structure leaves always one element in ThreadLocal set #413

Closed
sjappig opened this issue Mar 20, 2015 · 1 comment
Closed

Structure leaves always one element in ThreadLocal set #413

sjappig opened this issue Mar 20, 2015 · 1 comment

Comments

@sjappig
Copy link

sjappig commented Mar 20, 2015

StructureSet does never remove the element at index 0:

public boolean remove(Object o) {
    int idx = indexOf(o);
    if (idx != -1) {
        if (--count > 0) {
            elements[idx] = elements[count];
            elements[count] = null;
        }
        return true;
    }
    return false;
}

Can be fixed by moving the null assign outside of the if-block or by changing the > to >=.

@twall
Copy link
Contributor

twall commented Mar 21, 2015

Pull request and associated unit test are welcome. Confirmed by visual inspection and analysis, but I won’t be there for everyone’s build :)

On Mar 20, 2015, at 9:14 AM, Jari-Pekka Ryynänen [email protected] wrote:

StructureSet does never remove the element at index 0:

public boolean remove(Object
o) {

int idx =
indexOf(o);

if (idx != -1
) {

if (--count > 0
) {

elements[idx]

elements[count];
elements[count]
= null
;
}

return true
;
}

return false
;
}

Can be fixed by moving the null assign outside of the if-block or by changing the > to >=.


Reply to this email directly or view it on GitHub.

sjappig pushed a commit to sjappig/jna that referenced this issue Apr 8, 2015
twall added a commit that referenced this issue Apr 14, 2015
Issue #413: Structure leaves always one element in ThreadLocal set
@sjappig sjappig closed this as completed Apr 17, 2015
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