Re: allocated memory enlargement

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 26 Mar 2004, at 18:37, Tommy Carlier wrote:

> 
> http://click.topica.com/caab4CEb1dd66b6816za/ Crazy Aaron Enterprises
> 
> 
> > 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)

That last line makes it NOT a resize.

>  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

And that proves it, you are allocating new space while the old still exists. I 
don't have 512 megs of memory on the computer. I need to *resize*, not 
make more!

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu