...
| Code Block | ||||
|---|---|---|---|---|
| ||||
void f() {
int *array = new int[10];
// ...
delete array;
} |
Compliant Solution (array new[])
In the compliant solution, the code is fixed by replacing the call to delete with a call to delete [] to adhere to the correct pairing of memory allocation and deallocation functions.
| Code Block | ||||
|---|---|---|---|---|
| ||||
void f() {
int *array = new int[10];
// ...
delete[] array;
}
|
...