Reallocate() -- is this safe?
- Posted by Andy Serpa <ac at onehorseshy.com> Oct 13, 2002
- 357 views
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()?