Re: allocated memory enlargement
> Er,, i ever thought i'd be asking this, but if i have a block of memory
> allocated
> on windows, and i want to enlarge it without changing it contents, can i?
> How?
>
> Kat
If you have allocated it with the Euphoria-function allocate, you could do
it like this:
function resize_memblock(atom old_mem, integer old_size, integer new_size)
atom new_mem
if old_size = new_size then return old_mem end if
new_mem = allocate(new_size)
if old_size < new_size then
mem_copy(new_mem, old_mem, old_size)
else
mem_copy(new_mem, old_mem, new_size)
end if
free(old_mem)
return new_mem
end function
-- Using the function:
pointer = resize_memblock(pointer, size, size + 1000) -- adds 1000 bytes
to the memory block
--
Tommy Carlier
tommy online: http://users.pandora.be/tommycarlier
|
Not Categorized, Please Help
|
|