Reallocate() -- is this safe?

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

Hello,

function reallocate(atom old_addr, atom size)
atom new_addr
    new_addr = allocate(size)
    mem_copy(new_addr,old_addr,size) -- safe?
    free(old_addr)
    return new_addr
end function


If the new block is bigger we will be copying stuff beyond what was in 
the original block -- might we run up against the "edge" of available 
memory?  Is that possible, and what will happen?

If it is not safe, is there a way to tell how big the original block was 
without keeping explicit track at allocate()-time?

I don't suppose there is a way to call realloc() directly with some 
undocumented machine_func()?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu