1
0
Fork 0
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:
Sergey Prigogin 2009-10-04 06:05:22 +00:00
parent 3b408710f4
commit d0d9ec8b09

View file

@ -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;