-
Is this example correct? extern "C" {
__declspec(dllexport) void extern_solid_release(void* ptr) {
if (ptr) { // Проверяем, что указатель не нулевой
Mesh* mesh = reinterpret_cast<Mesh*>(ptr);
delete mesh;
mesh = nullptr; // Обнуляем указатель после удаления
}
}
} [DllImport(CallerCGAL.pathDll, CallingConvention = CallingConvention.Cdecl)]
private static extern void extern_solid_release(IntPtr ptr); |
Beta Was this translation helpful? Give feedback.
Answered by
ankofl
Oct 9, 2024
Replies: 1 comment 3 replies
-
Hi @ankofl. That is difficult to understand why that is related to CGAL. I see the word Actually, I do not even know which language you are programming into. I doubt anybody here can help you. Maybe ask on StackOverflow? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I apologize for the ambiguity
I write in C# NET.9 and I call C++ libraries compiled using header libraries via DllImport .h-files of CGAL. I am interested in the question: when I created a Mesh object (Polyhedron_3) in C++ code and sent a pointer to this object to C# code, how would it be correct to free memory from C# inside the unmanaged C++ code in which the Mesh object was created?
I tried to do it via:
delete mesh; mesh = null ptr;
But I am not sure that this will be correct.
Maybe Polyhedron_3 and Surface_Mesh objects have specialized methods to free up the memory they occupy?
Thanks!