List Info

Thread: MSVS2005 & realloc problems




MSVS2005 & realloc problems
user name
2006-10-02 23:12:38
Adam Peterson wrote:
> I have an win32 app built with MSVS2005.  realloc() is 
> failing consistently when being called and returning an
error 
> 22 (EINVAL Invalid argument).  The original block
allocated 
> was 65535, the new block attempting to realloc is
131070.  
> Plenty of memory available, no reason it should fail.  
> 
> Upon some further thought, it occurs to me that I'm
calling 
> two DLL's built on VC6.  Doing a quick 'Depends' on
them 
> returns KERNEL32, USER32, GDI32, & COMDLG32.

What matters is that the version of realloc matches the
version of malloc
used to make the original allocation.  If you are
reallocating memory that
was allocated by the DLL then I would not expect it to work.
 If you are
reallocating memory that was allocated in your application,
then the DLL
wouldn't come into it.

As a rule of thumb, reallocating (or deallocating) memory
that was allocated
in a separate DLL is always a bad idea.  COM gets around
this by making
objects responsible for deleting themselves.

Adelle.

------------------------------------------------------------
--------------
The MSVC list is hosted on a Windows NT(TM) machine running
L-Soft
international's LISTSERV(R) software.  For
subscription/signoff info
and archives, see http:/
/peach.ease.lsoft.com/archives/msvc.html .
                             COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa.ex
e?SHOWTPL=COPYRIGHT&L=MSVC
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )