mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug fix, the Arrays.binarySearch() return the
insertion index.
This commit is contained in:
parent
ace9aa5fd7
commit
e118256c06
2 changed files with 14 additions and 6 deletions
|
@ -58,11 +58,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
|
||||||
*/
|
*/
|
||||||
public ISymbol getSymbol(long addr) {
|
public ISymbol getSymbol(long addr) {
|
||||||
ISymbol[] syms = getSymbols();
|
ISymbol[] syms = getSymbols();
|
||||||
int i = Arrays.binarySearch(syms, new Long(addr));
|
int insertion = Arrays.binarySearch(syms, new Long(addr));
|
||||||
if (i < 0 || i >= syms.length) {
|
if (insertion > 0) {
|
||||||
|
return syms[insertion];
|
||||||
|
}
|
||||||
|
if (insertion == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return syms[i];
|
insertion = -insertion - 1;
|
||||||
|
return syms[insertion - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,11 +56,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
|
||||||
*/
|
*/
|
||||||
public ISymbol getSymbol(long addr) {
|
public ISymbol getSymbol(long addr) {
|
||||||
ISymbol[] syms = getSymbols();
|
ISymbol[] syms = getSymbols();
|
||||||
int i = Arrays.binarySearch(syms, new Long(addr));
|
int insertion = Arrays.binarySearch(syms, new Long(addr));
|
||||||
if (i < 0 || i >= syms.length) {
|
if (insertion > 0) {
|
||||||
|
return syms[insertion];
|
||||||
|
}
|
||||||
|
if (insertion == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return syms[i];
|
insertion = -insertion - 1;
|
||||||
|
return syms[insertion - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue