Re: realloc() / free() BYTE* immediately after malloc() fails
On Jun 6, 4:25 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
attibln wrote:
I'm having an odd problem with a project using VisualStudio 2005 Prof.
When I execute the program below I get this message:
Debug Assertion Failed
Program: ...
File: dbgheap.c
Line: 1252
Expression: _CrtIsValidHeapPointer(pUserData)
Consider asking questions about debugging in VC++ in the newsgroup
dedicated to VC++. Take a look at "microsoft.public.vc.*" hierarchy.
He's asking about a specific C++ problem, though.
[...]
realloc( byP_jpeg_file , 0 );
'realloc' is undefined. Consider including <cstdlib>.
The behaviour of 'realloc' with 'size' passed as 0 is implementation
defined. You should consider asking in the newsgroup for your C++
compiler (see above).
The behavior he is seeing is not among the allowed behaviors;
all that is allowed is that either realloc return NULL, or that
it return a value "as if" the argument wasn't 0.
It's hard to say what the problem is, but most of the time,
these sort of errors are due to the free space arena being
corrupted---writing beyond the end of allocated memory, or
something like that. And finding such problems is difficult,
because the symptoms don't appear until long after the actual
error has occurred.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34