GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Sep-2004, 02:51
Marius Marius is offline
New Member
 
Join Date: Sep 2004
Posts: 1
Marius is on a distinguished road
Question

Non-local heaps and assertion errors


Hello,

I am developing an application that makes use of rather advanced memory allocation techniques. My application makes use of "plug-in modules" in the form of DLLs that are loaded at runtime. The problem is this: the DLL exports a function that is passed a pointer to a class. This pointer is passed by the application. Now, the DLL must be able to call a member function, accessed through the passed pointer. This function allocates memory. Whenever this function is called, though, the application generates an assertion failure. I looked at the MFC code and found that an assertion error will be generated if it encounters a pointer to non-local memory - which is clearly the case here.

How can I work around this?

Thank you,
marius.
  #2  
Old 03-Sep-2004, 06:45
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 960
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
Quote:
Originally Posted by Marius
Hello,

I am developing an application that makes use of rather advanced memory allocation techniques. My application makes use of "plug-in modules" in the form of DLLs that are loaded at runtime. The problem is this: the DLL exports a function that is passed a pointer to a class. This pointer is passed by the application. Now, the DLL must be able to call a member function, accessed through the passed pointer. This function allocates memory. Whenever this function is called, though, the application generates an assertion failure. I looked at the MFC code and found that an assertion error will be generated if it encounters a pointer to non-local memory - which is clearly the case here.

How can I work around this?

Thank you,
marius.

Don't you mean a pointer to an instance of the class (an object)?
Well, do you instantiate the class the pointer is pointing to? If you want to call a (non-static) method, you should have an instance of the class, right?
Just "export" this class from the dll also, make an instance of it, and pass a pointer to it.

Hope I got this right - if not, please explain.

Best regards,
Luci
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:19.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.