2023-07-23 20:56:52 -04:00
|
|
|
realloc(ptr, new_size)
|
2023-07-23 09:35:32 -04:00
|
|
|
{
|
2023-07-23 20:56:52 -04:00
|
|
|
local block_ptr;
|
|
|
|
local new_space;
|
|
|
|
local i;
|
2023-07-23 09:35:32 -04:00
|
|
|
|
2023-07-23 20:56:52 -04:00
|
|
|
new_space = galloc(new_size);
|
|
|
|
if (new_space == NULL)
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
return (NULL);
|
|
|
|
}
|
2023-07-23 09:35:32 -04:00
|
|
|
if (ptr == NULL)
|
2023-07-23 20:56:52 -04:00
|
|
|
return new_space;
|
|
|
|
block_ptr = ptr - LOCATION_DATA;
|
|
|
|
i = 0;
|
2023-07-23 09:35:32 -04:00
|
|
|
loop
|
|
|
|
{
|
2023-07-23 20:56:52 -04:00
|
|
|
if (i == new_size | i == [block_ptr + LOCATION_SIZE])
|
2023-07-23 09:35:32 -04:00
|
|
|
break;
|
2023-07-23 20:56:52 -04:00
|
|
|
[new_space + i] = [ptr + i];
|
|
|
|
i++;
|
2023-07-23 09:35:32 -04:00
|
|
|
}
|
|
|
|
free(ptr);
|
2023-07-23 20:56:52 -04:00
|
|
|
return new_space;
|
2023-07-23 09:35:32 -04:00
|
|
|
}
|