Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Memory deallocation Pin
Stephen Hewitt2-Feb-11 4:26
Stephen Hewitt2-Feb-11 4:26 
AnswerRe: Memory deallocation Pin
Andrew Brock2-Feb-11 4:32
Andrew Brock2-Feb-11 4:32 
QuestionRe: Memory deallocation Pin
csrss2-Feb-11 4:53
csrss2-Feb-11 4:53 
AnswerRe: Memory deallocation Pin
Aescleal2-Feb-11 4:49
Aescleal2-Feb-11 4:49 
GeneralRe: Memory deallocation Pin
csrss2-Feb-11 5:21
csrss2-Feb-11 5:21 
GeneralRe: Memory deallocation Pin
Aescleal2-Feb-11 5:54
Aescleal2-Feb-11 5:54 
GeneralRe: Memory deallocation Pin
csrss2-Feb-11 6:16
csrss2-Feb-11 6:16 
Answer... [modified] Pin
csrss2-Feb-11 6:46
csrss2-Feb-11 6:46 
Alright, i was so lame.

extern "C"{

	__declspec(dllexport)void Stuff(wchar_t *&out)
	{
		wchar_t *String = L"test string whatever";
		out = (wchar_t *)malloc(sizeof(wchar_t *) * wcslen(String) + 1);
		wcscpy(out, String);
	}

	__declspec(dllexport)void FreeMem(void *Ptr)
	{
		if(Ptr != NULL)
		{
			free(Ptr);
			Ptr = NULL;
		}
	}
}


[DllImport("testdll.dll")]
public static extern void Stuff(ref IntPtr ptr);

[DllImport("testdll.dll")]
public static extern void FreeMem(IntPtr ptr);

int i = 10000000;
while(i > 0)
{
    IntPtr ptr = IntPtr.Zero;
    testdll.Stuff(ref ptr);
    testdll.FreeMem(ptr);
    i--;
}


No crash. Seems to be the best solution so far.
011011010110000101100011011010000110100101101110
0110010101110011
modified on Wednesday, February 2, 2011 7:39 PM

GeneralRe: ... Pin
Andrew Brock2-Feb-11 16:54
Andrew Brock2-Feb-11 16:54 
GeneralRe: ... Pin
csrss2-Feb-11 22:41
csrss2-Feb-11 22:41 
AnswerRe: Memory deallocation Pin
Stefan_Lang3-Feb-11 6:38
Stefan_Lang3-Feb-11 6:38 
Question[REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Curtis Tong1-Feb-11 23:38
Curtis Tong1-Feb-11 23:38 
GeneralRe: [REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Malli_S1-Feb-11 23:57
Malli_S1-Feb-11 23:57 
AnswerRe: [REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Malli_S2-Feb-11 0:04
Malli_S2-Feb-11 0:04 
GeneralRe: [REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Andrew Brock2-Feb-11 0:51
Andrew Brock2-Feb-11 0:51 
GeneralRe: [REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Malli_S2-Feb-11 0:57
Malli_S2-Feb-11 0:57 
AnswerRe: [REQUEST] TabControl Sample Code (Visual C++, Win32, Win32 Project) with Tutorial on what to edit to customize it Pin
Andrew Brock2-Feb-11 0:51
Andrew Brock2-Feb-11 0:51 
QuestionSong and video Parsing Pin
VikramRathod1-Feb-11 22:30
VikramRathod1-Feb-11 22:30 
AnswerRe: Song and video Parsing Pin
Cedric Moonen1-Feb-11 23:12
Cedric Moonen1-Feb-11 23:12 
AnswerRe: Song and video Parsing Pin
Emilio Garavaglia2-Feb-11 1:59
Emilio Garavaglia2-Feb-11 1:59 
JokeRe: Song and video Parsing Pin
Cool_Dev2-Feb-11 2:16
Cool_Dev2-Feb-11 2:16 
GeneralRe: Song and video Parsing Pin
VikramRathod10-Feb-11 20:15
VikramRathod10-Feb-11 20:15 
Questionhow do i sync two places.sqlite..? Pin
yogish2931-Feb-11 19:58
yogish2931-Feb-11 19:58 
AnswerRe: how do i sync two places.sqlite..? Pin
User 74293381-Feb-11 20:13
professionalUser 74293381-Feb-11 20:13 
GeneralRe: how do i sync two places.sqlite..? Pin
yogish2931-Feb-11 20:17
yogish2931-Feb-11 20:17 

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.