Skip to content

Commit

Permalink
fix: add remaining deallocation memory
Browse files Browse the repository at this point in the history
  • Loading branch information
hozlucas28 committed Sep 28, 2024
1 parent 6de0495 commit 1d6c1ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ int isStrIn(char* str, char* arr[], int size) {

char** new2DArray(int rows, int cols) {
char** bidimensionalArr;

int i;
int j;

bidimensionalArr = malloc(rows * sizeof(char*));
if (bidimensionalArr == NULL) {
Expand All @@ -66,6 +68,7 @@ char** new2DArray(int rows, int cols) {
for (i = 0; i < rows; i++) {
*(bidimensionalArr + i) = malloc(cols * sizeof(char));
if (*(bidimensionalArr + i) == NULL) {
for (j = 0; j < i; j++) free(*(bidimensionalArr + j));
printf("Memory allocation failed!\n");
exit(EXIT_FAILURE);
}
Expand All @@ -76,8 +79,7 @@ char** new2DArray(int rows, int cols) {

void sleep(int miliseconds) {
clock_t startTime = clock();
while (clock() < (startTime + miliseconds))
;
while (clock() < (startTime + miliseconds));
}

int strcmpi(const char* str01, const char* str02) {
Expand Down

0 comments on commit 1d6c1ce

Please sign in to comment.