|
From: Dimitri Papadopoulos-O. <pap...@sh...> - 2004-10-27 10:06:27
|
Hi,
> I became a little bit confused doing memchecks using c++ classes.
> One of those classes maintains a mem area which is frequently resized using
> realloc.
> The Code segment looks perfectly alright to me...
>
> void MyClass::resize(size_t n) {
> char *buf;
>
> if (n >= _size) {
> if (!(buf = (char*)realloc(_buf,n+1)))
> throw std::bad_alloc();
> _buf = buf;
> _size = n + 1;
> }
> }
How was _buf allocated in the first place? malloc or new[]?
Dimitri
|