1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2025-01-10 17:32:05 +05:30

reverse-ramdisk.c: reorder operations to improve speed

This commit is contained in:
パチュリー・ノーレッジ 2023-12-27 21:58:50 +03:00
parent 52aa23d585
commit df2d4f3dd9
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -81,12 +81,14 @@ int tf_alloc(size_t n, size_t type_size) {
return -1; return -1;
} }
// Assign the ID and file path // Assign the ID, file path, file handler
temp_file->ID = num_temp_files; temp_file->ID = num_temp_files;
temp_file->file_path = strdup(file_path); temp_file->file_path = strdup(file_path);
temp_file->file = file; temp_file->file = file;
// Increase the number of temp files // Add the temp file to the array
temp_files[num_temp_files] = *temp_file;
num_temp_files++; num_temp_files++;
// Allocate/reallocate memory for the temp_files structure // Allocate/reallocate memory for the temp_files structure
@ -100,9 +102,6 @@ int tf_alloc(size_t n, size_t type_size) {
return -1; return -1;
} }
// Add the temp file to the array
temp_files[num_temp_files - 1] = *temp_file;
return temp_file->ID; return temp_file->ID;
} }