mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-26 11:30:03 +05:30
reverse-ramdisk.c: fix reallocation, reduce code
This commit is contained in:
parent
50a6998d59
commit
438d62dbcd
@ -146,14 +146,14 @@ int tf_free(int ID) {
|
|||||||
for (int i = index; i < num_temp_files - 1; i++)
|
for (int i = index; i < num_temp_files - 1; i++)
|
||||||
temp_files[(size_t) i] = temp_files[(size_t) i + 1];
|
temp_files[(size_t) i] = temp_files[(size_t) i + 1];
|
||||||
|
|
||||||
num_temp_files--;
|
|
||||||
|
|
||||||
// Reallocate memory for the temp_files array
|
// Reallocate memory for the temp_files array
|
||||||
temp_files = realloc(temp_files, num_temp_files * sizeof(TempFile));
|
if (--num_temp_files > 0) {
|
||||||
if (temp_files == NULL) {
|
if ((temp_files = realloc(temp_files, num_temp_files
|
||||||
|
* sizeof(TempFile))) == NULL) {
|
||||||
line_fail(-2);
|
line_fail(-2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
temp_files[index].locked = false;
|
temp_files[index].locked = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user