mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Allow input array of zero length.
This commit is contained in:
parent
3b408710f4
commit
d0d9ec8b09
1 changed files with 3 additions and 2 deletions
|
@ -43,7 +43,7 @@ public abstract class ArrayUtil {
|
|||
return array;
|
||||
}
|
||||
|
||||
Object[] temp = (Object[]) Array.newInstance(c, array.length * 2);
|
||||
Object[] temp = (Object[]) Array.newInstance(c, Math.max(array.length * 2, DEFAULT_LENGTH));
|
||||
System.arraycopy(array, 0, temp, 0, array.length);
|
||||
temp[array.length] = obj;
|
||||
return temp;
|
||||
|
@ -119,7 +119,8 @@ public abstract class ArrayUtil {
|
|||
return array;
|
||||
}
|
||||
|
||||
T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length * 2);
|
||||
T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(),
|
||||
Math.max(array.length * 2, DEFAULT_LENGTH));
|
||||
System.arraycopy(array, 0, temp, 0, array.length);
|
||||
temp[array.length] = obj;
|
||||
return temp;
|
||||
|
|
Loading…
Add table
Reference in a new issue