Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get a handle to a dialog... Pin
Nish Nishant24-Feb-03 13:33
sitebuilderNish Nishant24-Feb-03 13:33 
AnswerRe: how to get a handle to a dialog... Pin
valikac24-Feb-03 14:28
valikac24-Feb-03 14:28 
Generalc++ beginner: Make dll for Excel Pin
jorge garcia24-Feb-03 13:11
jorge garcia24-Feb-03 13:11 
GeneralDoModal functionality for CWnd Pin
João Paulo Figueira24-Feb-03 12:34
professionalJoão Paulo Figueira24-Feb-03 12:34 
GeneralRe: DoModal functionality for CWnd Pin
Nish Nishant24-Feb-03 13:13
sitebuilderNish Nishant24-Feb-03 13:13 
GeneralRe: DoModal functionality for CWnd Pin
João Paulo Figueira25-Feb-03 4:42
professionalJoão Paulo Figueira25-Feb-03 4:42 
GeneralCrystal Report and Record number !!! Pin
Hadi Rezaee24-Feb-03 10:05
Hadi Rezaee24-Feb-03 10:05 
Generalnew/delete between dll calls Pin
Dave_24-Feb-03 9:30
Dave_24-Feb-03 9:30 
I have created a dll with a function that creates an array of structures. The calling application supplies a pointer that gets filled in by the dll call. The application then loops through the number of structures created by the dll call, and makes use of the info.

My plan was to have the application do the clean up as it looped through the returned data. When I call delete within the loop, I get a crash/assertion that I think is telling me that the objects were created on a different heap.

Is there a better way to do this? I don't want to have the applications call a enumerateXXX() type call where they have to identify a callback. I thought it would be best to just have them call something like this:

<br />
applications code:<br />
<br />
int nNum = 0;<br />
DSTRUCT *pds = NULL;<br />
mydllGetData(&nNum,&pData);<br />
for (int x = 0;x < nNum;x++){<br />
  //use the data here<br />
  // ...<br />
  //free the allocated memory<br />
  delete pds;  //here's the problem<br />
  pds++;<br />
}<br />
<br />
dll code:<br />
mydllGetData(int *pNum,DSTRUCT &pds)<br />
{<br />
  //determine how many are to be created:<br />
  // ...<br />
  //create them<br />
  DSTRUCT *pNewDS = new DSTRUCT[15];<br />
  *pds = pNewDS;<br />
  *pNum = 15;<br />
<br />
}<br />


Thanks for any ideas you may have.
GeneralRe: new/delete between dll calls Pin
Chris Losinger24-Feb-03 9:45
professionalChris Losinger24-Feb-03 9:45 
GeneralRe: new/delete between dll calls Pin
Dave_24-Feb-03 10:04
Dave_24-Feb-03 10:04 
GeneralRe: new/delete between dll calls Pin
Chris Losinger24-Feb-03 10:10
professionalChris Losinger24-Feb-03 10:10 
GeneralRe: new/delete between dll calls Pin
Alvaro Mendez24-Feb-03 10:47
Alvaro Mendez24-Feb-03 10:47 
QuestionError returning CStringArray as function result? Pin
yasbas24-Feb-03 9:29
yasbas24-Feb-03 9:29 
AnswerRe: Error returning CStringArray as function result? Pin
Dave_24-Feb-03 9:33
Dave_24-Feb-03 9:33 
AnswerRe: Error returning CStringArray as function result? Pin
Christian Graus24-Feb-03 9:52
protectorChristian Graus24-Feb-03 9:52 
GeneralRe: Error returning CStringArray as function result? Pin
Alvaro Mendez24-Feb-03 10:27
Alvaro Mendez24-Feb-03 10:27 
GeneralRe: Error returning CStringArray as function result? Pin
Christian Graus24-Feb-03 10:29
protectorChristian Graus24-Feb-03 10:29 
GeneralRe: Error returning CStringArray as function result? Pin
Alvaro Mendez24-Feb-03 11:03
Alvaro Mendez24-Feb-03 11:03 
GeneralRe: Error returning CStringArray as function result? Pin
Christian Graus24-Feb-03 11:31
protectorChristian Graus24-Feb-03 11:31 
Generaldeleting a CDialog... Pin
ns24-Feb-03 9:03
ns24-Feb-03 9:03 
GeneralRe: deleting a CDialog... Pin
Alvaro Mendez24-Feb-03 9:15
Alvaro Mendez24-Feb-03 9:15 
GeneralRe: deleting a CDialog... Pin
ns24-Feb-03 9:22
ns24-Feb-03 9:22 
GeneralRe: deleting a CDialog... Pin
Alvaro Mendez24-Feb-03 10:22
Alvaro Mendez24-Feb-03 10:22 
Generaloay, got it! Quick ques.. Pin
ns25-Feb-03 2:14
ns25-Feb-03 2:14 
GeneralRe: oay, got it! Quick ques.. Pin
Alvaro Mendez25-Feb-03 4:25
Alvaro Mendez25-Feb-03 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.