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:
parent
eae82bcceb
commit
d9dfe5edf2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user