Hello,
Does the renew operator delete the previously allocated memory?
Like if some memory was allocated with new and then I call the renew operator and a completely new block of memory will be allocated, will the old block be freed?
Hopefully it will.
Does the renew operator delete the previously allocated mem?
Re: Does the renew operator delete the previously allocated mem?
Hi fedor.
Yes the renew allocator either reuses, or frees then allocates a new block of memory.
It works similarly to the C function 'realloc'.
Typical usage:
Use with complete peace of mind. No memory leaks.
Also note the zeroing versions:
Which will only zero out the new portion of renew'ed memory.
Yes the renew allocator either reuses, or frees then allocates a new block of memory.
It works similarly to the C function 'realloc'.
Typical usage:
Code: Select all
byte * mem = new byte[10];
mem = renew mem byte[20];
Also note the zeroing versions:
Code: Select all
byte * mem = new0 byte[10];
mem = renew0 mem byte[20];