1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-11-10 06:42:02 +05:30

reverse-ramdisk.c: improve memory management

This commit is contained in:
Intel A80486DX2-66 2023-12-27 21:45:53 +03:00
parent eae82bcceb
commit d9dfe5edf2
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -88,8 +88,12 @@ int tf_alloc(size_t n, size_t type_size) {
// Increase the number of temp files
num_temp_files++;
// Reallocate memory for the temp_files array
temp_files = realloc(temp_files, num_temp_files * sizeof(TempFile));
// Allocate/reallocate memory for the temp_files structure
if (temp_files == NULL)
temp_files = malloc(sizeof(TempFile));
else
temp_files = realloc(temp_files,
(size_t) num_temp_files * sizeof(TempFile));
if (temp_files == NULL) {
line_fail(-2);
return -1;