Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 4da7290

Browse files
🔒 Secure Array Sharing ++
1 parent 198c0b8 commit 4da7290

File tree

8 files changed

+11
-3
lines changed

8 files changed

+11
-3
lines changed
34 Bytes
Binary file not shown.
98 Bytes
Binary file not shown.
17 Bytes
Binary file not shown.
104 Bytes
Binary file not shown.

‎src/SomeUtils/DynamicArray/DynamicArray.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public T[] getArray(){
7878
return returnMe;
7979
}
8080
public T[] getRealArray(){
81+
final int l=underlyingArr.length;
82+
@SuppressWarnings("unchecked")
83+
final T[] copyOf=(T[])new Object[l];
84+
System.arraycopy(underlyingArr, 0, copyOf, 0, l);
8185
return underlyingArr;
8286
}
8387
}

‎src/SomeUtils/Pattern/PatternFinder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ public String[][] toArray(){
135135
return getArray();
136136
}
137137
public String[][] getArray(){
138-
return output;
138+
final String[][] copyOf=new String[output.length][2];
139+
System.arraycopy(output, 0, copyOf, 0, output.length);
140+
return copyOf;
139141
}
140142
}

‎src/SomeUtils/ProgressBar/ProgressBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public int getMaxValue(){
3333
return values[1];
3434
}
3535
public int[] getValues(){
36-
return values;
36+
return newint[]{values[0], values[1]};
3737
}
3838
public void setValue(final int newValue){
3939
values[0]=newValue;

‎src/SomeUtils/TerminalMap/TerminalMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public char[] getColumn(final int x){
9393
return temp;
9494
}
9595
public char[][] getMap(){
96-
return map;
96+
final char[][] copyOf=new char[map.length][map[0].length];
97+
System.arraycopy(map, 0, copyOf, 0, map.length);
98+
return copyOf;
9799
}
98100
public void printMap(){
99101
printMap(false, false);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /