27 lines
392 B
Plaintext
27 lines
392 B
Plaintext
realloc(ptr, new_size)
|
|
{
|
|
local block_ptr;
|
|
local new_space;
|
|
local i;
|
|
|
|
new_space = galloc(new_size);
|
|
if (new_space == NULL)
|
|
{
|
|
free(ptr);
|
|
return (NULL);
|
|
}
|
|
if (ptr == NULL)
|
|
return new_space;
|
|
block_ptr = ptr - LOCATION_DATA;
|
|
i = 0;
|
|
loop
|
|
{
|
|
if (i == new_size | i == [block_ptr + LOCATION_SIZE])
|
|
break;
|
|
[new_space + i] = [ptr + i];
|
|
i++;
|
|
}
|
|
free(ptr);
|
|
return new_space;
|
|
}
|