Commit MetaInfo

Revision70500b3279f51ea823ce56cabfd13a1111b93534 (tree)
Time2011-01-24 08:22:25
AuthorFace
CommiterFace

Log Message

OrbiterExtensions: added CleanVesselEvents

This additional function is needed to get rid of allocated elements. Unfortunately, the heap in the late-bound DLL is not accessable from outside.

Change Summary

Incremental Difference

diff -r 54e0324a8ec9 -r 70500b3279f5 Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp
--- a/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp Sun Jan 23 23:59:35 2011 +0100
+++ b/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp Mon Jan 24 00:22:25 2011 +0100
@@ -310,5 +310,17 @@
310310 return i;
311311 }
312312
313+// Cleans the specified recorded events.
314+// Returns 0
315+__declspec(dllexport) int __cdecl CleanVesselEvents(char **event_types, char **events, int size)
316+{
317+ for(int i=0;i<size;i++)
318+ {
319+ delete [] event_types[i];
320+ delete [] events[i];
321+ }
322+ return 0;
323+}
324+
313325 }
314326 }
diff -r 54e0324a8ec9 -r 70500b3279f5 Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.h
--- a/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.h Sun Jan 23 23:59:35 2011 +0100
+++ b/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.h Mon Jan 24 00:22:25 2011 +0100
@@ -66,4 +66,9 @@
6666 // -4 if library not found
6767 int GetVesselEvents(VESSEL *handle, double *mjds, char **event_types, char **events, int size);
6868
69+// Cleans the specified recorded events.
70+// Returns 0 if successfull
71+// -4 if library not found
72+int CleanVesselEvents(char **event_types, char **events, int size);
73+
6974 }
\ No newline at end of file
diff -r 54e0324a8ec9 -r 70500b3279f5 Orbitersdk/samples/AscensionUltra/VirtualDockingTunnelLibrary.cpp
--- a/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnelLibrary.cpp Sun Jan 23 23:59:35 2011 +0100
+++ b/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnelLibrary.cpp Mon Jan 24 00:22:25 2011 +0100
@@ -16,6 +16,7 @@
1616 typedef int (* MAPFUNC) (VESSEL *, OBJHANDLE);
1717 typedef float (* FLOATGETTER) (void);
1818 typedef int (* GETEVENTFUNC) (VESSEL *, double *, char **, char **, int);
19+typedef int (* CLEANFUNC) (char **, char **, int);
1920
2021 // ==============================================================
2122 // Global variables
@@ -32,6 +33,7 @@
3233 HOOKFUNC g_RecordVesselEvents;
3334 VESSELFUNC g_DeleteVesselEvents;
3435 GETEVENTFUNC g_GetVesselEvents;
36+CLEANFUNC g_CleanVesselEvents;
3537 }
3638
3739 // Initializes the virtual docking hook.
@@ -55,9 +57,10 @@
5557 g_RecordVesselEvents=(HOOKFUNC)GetProcAddress(g_Module, "RecordVesselEvents");
5658 g_DeleteVesselEvents=(VESSELFUNC)GetProcAddress(g_Module, "DeleteVesselEvents");
5759 g_GetVesselEvents=(GETEVENTFUNC)GetProcAddress(g_Module, "GetVesselEvents");
60+ g_CleanVesselEvents=(CLEANFUNC)GetProcAddress(g_Module, "CleanVesselEvents");
5861 float version=GetVersion();
5962 if (((DWORD)g_Init & (DWORD)g_Exit & (DWORD)g_SetDockState & (DWORD)g_GetVersion)==NULL ||
60- (((DWORD)g_InitHook & (DWORD)g_ExitHook & (DWORD)g_RecordVesselEvents & (DWORD)g_DeleteVesselEvents & (DWORD)g_GetVesselEvents)==NULL && version>0.1f))
63+ (((DWORD)g_InitHook & (DWORD)g_ExitHook & (DWORD)g_RecordVesselEvents & (DWORD)g_DeleteVesselEvents & (DWORD)g_GetVesselEvents & (DWORD)g_CleanVesselEvents)==NULL && version>0.1f))
6164 {
6265 FreeLibrary(g_Module);
6366 g_GetVersion=(FLOATGETTER)NULL;
@@ -124,4 +127,9 @@
124127 // >0 number of read events
125128 // -1 if vessel was not registered
126129 // -4 if library not found
127-int OrbiterExtensions::GetVesselEvents(VESSEL *handle, double *mjds, char **event_types, char **events, int size){if (!g_GetVesselEvents) return -4; return g_GetVesselEvents(handle, mjds, event_types, events, size);}
\ No newline at end of file
130+int OrbiterExtensions::GetVesselEvents(VESSEL *handle, double *mjds, char **event_types, char **events, int size){if (!g_GetVesselEvents) return -4; return g_GetVesselEvents(handle, mjds, event_types, events, size);}
131+
132+// Cleans the specified recorded events.
133+// Returns 0 if successfull
134+// -4 if library not found
135+int OrbiterExtensions::CleanVesselEvents(char **event_types, char **events, int size){if (!g_CleanVesselEvents) return -4; return g_CleanVesselEvents(event_types, events, size);}
\ No newline at end of file
Show on old repository browser