mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-10 17:32:05 +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
|
// Increase the number of temp files
|
||||||
num_temp_files++;
|
num_temp_files++;
|
||||||
|
|
||||||
// Reallocate memory for the temp_files array
|
// Allocate/reallocate memory for the temp_files structure
|
||||||
temp_files = realloc(temp_files, num_temp_files * sizeof(TempFile));
|
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) {
|
if (temp_files == NULL) {
|
||||||
line_fail(-2);
|
line_fail(-2);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user