mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-10 08:27:48 +05:30
reverse-ramdisk.c: improve len_digit
calculation
This commit is contained in:
parent
438d62dbcd
commit
db83a7a2e4
@ -64,7 +64,7 @@ int tf_alloc(size_t n, size_t type_size) {
|
|||||||
if (num_temp_files == 0)
|
if (num_temp_files == 0)
|
||||||
len_digit = 1;
|
len_digit = 1;
|
||||||
else
|
else
|
||||||
len_digit = (size_t) ceil(log((double) num_temp_files + 1.) / log(10.));
|
len_digit = (size_t) floor(log10((double) num_temp_files)) + 1;
|
||||||
size_t file_path_len = len_digit + strlen("tf_.tmp");
|
size_t 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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user