diff --git a/c-programming/experiments/reverse-ramdisk.c b/c-programming/experiments/reverse-ramdisk.c index 96bda32..20bb066 100644 --- a/c-programming/experiments/reverse-ramdisk.c +++ b/c-programming/experiments/reverse-ramdisk.c @@ -80,12 +80,12 @@ int tf_alloc(size_t n, size_t type_size) { DBG_PRINT("tf_alloc(%zu, %zu)\n", n, type_size); // Create an empty file - size_t len_digit; - if (num_temp_files == 0) - len_digit = 1; - else - len_digit = (size_t) floor(log10((double) num_temp_files)) + 1; - size_t file_path_len = len_digit + strlen("tf_.tmp"); + size_t len_digit = + num_temp_files == 0 ? + 1 + : + (size_t) floor(log10((double) num_temp_files)) + 1, + file_path_len = len_digit + strlen("tf_.tmp"); char* file_path = malloc((file_path_len + 1) * sizeof(char)); if (file_path == NULL) { LINE_FAIL(-2); @@ -123,10 +123,10 @@ int tf_alloc(size_t n, size_t type_size) { temp_file->file = file; // Allocate/reallocate memory for the temp_files structure - if (temp_files == NULL) - temp_files = malloc(sizeof(TempFile)); - else - temp_files = realloc(temp_files, num_temp_files * sizeof(TempFile)); + temp_files = temp_files == NULL ? + malloc(sizeof(TempFile)) + : + realloc(temp_files, num_temp_files * sizeof(TempFile)); if (temp_files == NULL) { LINE_FAIL(-2); return -1;