1
0
Fork 0
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:
Alain Magloire 2003-11-20 17:06:20 +00:00
parent ace9aa5fd7
commit e118256c06
2 changed files with 14 additions and 6 deletions

View file

@ -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];
} }
/** /**

View file

@ -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];
} }
/** /**