On 2005/05/31, Thomas Frieden wrote:
So I was wonder is its extend or just allocating a new block of memory?
Both.
If the original pointer is NULL, it is equivalent to a malloc. If it's not, it will re-allocate the block, and the contents will remain the same (up to min(oldsize, newsize)). If size is zero, it's equivalent to a free.
Note that it does not necessarily operate in-place. It might also allocate at a new address, and copy the contents.
Here's a link to the manpage: http://www.rt.com/man/realloc.3.html
I have been trying to use exec's realloc and my resoult looks like this
APTR my_realloc( struct LibusbBase *libBase, APTR mem, uint32 size ) { struct LibusbBase *libBase; APTR retval;
libBase = (struct LibusbBase *)Self->Data.LibBase;
if ( mem ) { retval = libBase->lib_IExec->AllocVec( size, MEMF_CLEAR|MEMF_PUBLIC ); } else { libBase->lib_IExec->ReallocVec( mem, size, MEMF_CLEAR|MEMF_PUBLIC ); retval = mem; }
return( retval ); }
But I not really sure this is ok, what happens if reallocvec() need to alloc a new block and move the memory? how do I get the new mem pointer?
Regards Rene W. Olsen