Skip to content

Commit d142f8b

Browse files
committed
fix: add remaining deallocation memory
1 parent 8160979 commit d142f8b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libs/utilities.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ int isStrIn(char* str, char* arr[], int size) {
5555

5656
char** new2DArray(int rows, int cols) {
5757
char** bidimensionalArr;
58+
5859
int i;
60+
int j;
5961

6062
bidimensionalArr = malloc(rows * sizeof(char*));
6163
if (bidimensionalArr == NULL) {
@@ -66,6 +68,7 @@ char** new2DArray(int rows, int cols) {
6668
for (i = 0; i < rows; i++) {
6769
*(bidimensionalArr + i) = malloc(cols * sizeof(char));
6870
if (*(bidimensionalArr + i) == NULL) {
71+
for (j = 0; j < i; j++) free(*(bidimensionalArr + j));
6972
printf("Memory allocation failed!\n");
7073
exit(EXIT_FAILURE);
7174
}
@@ -76,8 +79,7 @@ char** new2DArray(int rows, int cols) {
7679

7780
void sleep(int miliseconds) {
7881
clock_t startTime = clock();
79-
while (clock() < (startTime + miliseconds))
80-
;
82+
while (clock() < (startTime + miliseconds));
8183
}
8284

8385
int strcmpi(const char* str01, const char* str02) {

0 commit comments

Comments
 (0)