TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Coridon Henshaw
from: Peter Fitzsimmons
date: 1996-03-08 02:25:44
subject: Wierd Watcom problem w/ DLLs

CH> I have a program here that attempts to use a DLL for a 
 CH> portion of it's functions.  The problem is that when I 
 CH> realloc or free a pointer allocated by the DLL in the 
 CH> program's EXE, the thing crashes.

Then don't do that .

You are correct in your thinking that there are two runtimes here; one in
the DLL and one in the EXE.

The quickest solution is to use the version of the runtime that is itself a
dll (so that your EXE and DLLs all use the same runtime) -- but I don't
think Watcom supports this feature.

A better solution would be to change your design -- I don't think it is a
good design to allocate memory in one place (a "place" being the
OOP "class" idea) and free it somewhere else -- same goes for
opening/closing files, etc.

If you have already made the decision that some code is so isolated that it
belongs in a DLL,  I find it odd that such an intimate relationship exists
between your EXE and DLL.

I usually write a DLL interface (ie: the APIs it exports) as if it will be
called from a different language (or C compiler,  where you _definitely_
can't let the runtimes mix).



--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.