mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-27 14:50:23 +05:30
C: reverse-ramdisk.c: make use of ternary operator
This commit is contained in:
parent
544ae06944
commit
9c47cde541
@ -80,12 +80,12 @@ int tf_alloc(size_t n, size_t type_size) {
|
|||||||
DBG_PRINT("tf_alloc(%zu, %zu)\n", n, type_size);
|
DBG_PRINT("tf_alloc(%zu, %zu)\n", n, type_size);
|
||||||
|
|
||||||
// Create an empty file
|
// Create an empty file
|
||||||
size_t len_digit;
|
size_t len_digit =
|
||||||
if (num_temp_files == 0)
|
num_temp_files == 0 ?
|
||||||
len_digit = 1;
|
1
|
||||||
else
|
:
|
||||||
len_digit = (size_t) floor(log10((double) num_temp_files)) + 1;
|
(size_t) floor(log10((double) num_temp_files)) + 1,
|
||||||
size_t file_path_len = len_digit + strlen("tf_.tmp");
|
file_path_len = len_digit + strlen("tf_.tmp");
|
||||||
char* file_path = malloc((file_path_len + 1) * sizeof(char));
|
char* file_path = malloc((file_path_len + 1) * sizeof(char));
|
||||||
if (file_path == NULL) {
|
if (file_path == NULL) {
|
||||||
LINE_FAIL(-2);
|
LINE_FAIL(-2);
|
||||||
@ -123,10 +123,10 @@ int tf_alloc(size_t n, size_t type_size) {
|
|||||||
temp_file->file = file;
|
temp_file->file = file;
|
||||||
|
|
||||||
// Allocate/reallocate memory for the temp_files structure
|
// Allocate/reallocate memory for the temp_files structure
|
||||||
if (temp_files == NULL)
|
temp_files = temp_files == NULL ?
|
||||||
temp_files = malloc(sizeof(TempFile));
|
malloc(sizeof(TempFile))
|
||||||
else
|
:
|
||||||
temp_files = realloc(temp_files, num_temp_files * sizeof(TempFile));
|
realloc(temp_files, num_temp_files * sizeof(TempFile));
|
||||||
if (temp_files == NULL) {
|
if (temp_files == NULL) {
|
||||||
LINE_FAIL(-2);
|
LINE_FAIL(-2);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user