diff --git a/c-programming/experiments/reverse-ramdisk.c b/c-programming/experiments/reverse-ramdisk.c index 5e57bde..ff35c95 100644 --- a/c-programming/experiments/reverse-ramdisk.c +++ b/c-programming/experiments/reverse-ramdisk.c @@ -170,11 +170,13 @@ int tf_free(int ID) { // Reallocate memory for the temp_files array if (--num_temp_files > 0) { DBG_PRINT("num_temp_files = %zu\n", num_temp_files); - if ((temp_files = realloc(temp_files, num_temp_files - * sizeof(TempFile))) == NULL) { - LINE_FAIL(-2); + TempFile* new_temp_files_ptr = realloc(temp_files, num_temp_files * + sizeof(TempFile)); + if (new_temp_files_ptr == NULL) { + LINE_FAIL(-3); return -1; } + temp_files = new_temp_files_ptr; } temp_files[index].locked = false;