You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
5.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Dr.Frucht Systems Ltd.
  3. // Copyright © 2000-2016. All Rights Reserved.
  4. // Version 2.0 3/30/2016
  5. // Last modification: 3/30/2016
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: basicEvent.cpp
  9. // AUTHOR: gagua
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of basicEvent.cpp
  13. //----------------------------------------------------------------------------
  14. //
  15. #include "basicEvent.h"
  16. #include "basicFunctionality.h"
  17. void utilizeBasicEvent(EVENT_CONTAINER & Evt)
  18. {
  19. if (Evt.m_pHumanReadableMsg != NULL)
  20. {
  21. free( Evt.m_pHumanReadableMsg ); // The mem is allocated by malloc!!
  22. Evt.m_pHumanReadableMsg = NULL;
  23. };
  24. if (Evt.m_pEvtData != NULL)
  25. {
  26. switch (Evt.m_eType)
  27. {
  28. case EVT_FH_MISSION_BEGIN:
  29. case EVT_FH_BUSY:
  30. case EVT_FH_CANCEL_ACTION : free(Evt.m_pEvtData); break; // allocated with malloc everywhere
  31. case EVT_FH_FLY_TO :
  32. case EVT_FH_WAYPOINT :
  33. case EVT_FH_DEST_REACHED :
  34. case EVT_FH_JAMER_ON :
  35. case EVT_FH_JAMER_OFF :
  36. case EVT_FH_TARGET_LOCKED :
  37. case EVT_FH_INTERCEPT_BEGIN:
  38. case EVT_FH_INTERCEPT_OK :
  39. case EVT_FH_INTERCEPT_NOK :
  40. case EVT_FH_MISSION_END : free(Evt.m_pEvtData); break; // allocated with malloc everywhere
  41. case EVT_TARGET_1D:
  42. case EVT_TARGET_2D_WHITE:
  43. case EVT_TARGET_2D_BLACK:
  44. case EVT_TARGET_3D_WHITE:
  45. case EVT_TARGET_3D_BLACK:
  46. case EVT_CAMERA_MOVE_TO:
  47. {
  48. free(Evt.m_pEvtData); // allocated with malloc everywhere (delete was an allocator mismatch)
  49. break;
  50. };
  51. default: free(Evt.m_pEvtData);
  52. };
  53. };
  54. Evt.m_pEvtData = NULL;
  55. Evt.m_eType = EVT_NOINIT;
  56. }
  57. void utilizeBasicEvent(EVENT_CONTAINER *& Evt)
  58. {
  59. if (Evt == NULL)
  60. {
  61. return;
  62. }
  63. if (Evt->m_pHumanReadableMsg != NULL)
  64. {
  65. free( Evt->m_pHumanReadableMsg ); // The mem is allocated by malloc!!
  66. Evt->m_pHumanReadableMsg = NULL;
  67. };
  68. if (Evt->m_pEvtData != NULL)
  69. {
  70. switch (Evt->m_eType)
  71. {
  72. case EVT_FH_MISSION_BEGIN:
  73. case EVT_FH_BUSY:
  74. case EVT_FH_CANCEL_ACTION : free(Evt->m_pEvtData); break; // allocated with malloc everywhere
  75. case EVT_FH_FLY_TO :
  76. case EVT_FH_WAYPOINT :
  77. case EVT_FH_DEST_REACHED :
  78. case EVT_FH_JAMER_ON :
  79. case EVT_FH_JAMER_OFF :
  80. case EVT_FH_TARGET_LOCKED :
  81. case EVT_FH_INTERCEPT_BEGIN:
  82. case EVT_FH_INTERCEPT_OK :
  83. case EVT_FH_INTERCEPT_NOK :
  84. case EVT_FH_MISSION_END : free(Evt->m_pEvtData); break; // allocated with malloc everywhere
  85. case EVT_TARGET_1D:
  86. case EVT_TARGET_2D_WHITE:
  87. case EVT_TARGET_2D_BLACK:
  88. case EVT_TARGET_3D_WHITE:
  89. case EVT_TARGET_3D_BLACK:
  90. case EVT_CAMERA_MOVE_TO:
  91. {
  92. free(Evt->m_pEvtData); // allocated with malloc everywhere (delete was an allocator mismatch)
  93. break;
  94. };
  95. default: free(Evt->m_pEvtData);
  96. };
  97. };
  98. free(Evt);
  99. Evt = NULL;
  100. }
  101. static uint32_t EventSeed_Counter = 0;
  102. EVENT_CONTAINER * createBasicEvent(uint64_t SRC, basicEventClassID Class, basicEventTypeID Type, char * RefUUID, char * Msg, void * Data, uint32_t tss, uint16_t tms)
  103. {
  104. EVENT_CONTAINER * tEvent;
  105. tEvent = (EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER));
  106. if (tEvent)
  107. {
  108. if (tss == 0)
  109. {
  110. time_t t = time(NULL);
  111. localtime_r( &t, &tEvent->sTS );// MT safe
  112. tEvent->m_UMSTS = getMilliseconds();
  113. }
  114. else
  115. {
  116. time_t t = (time_t) tss;
  117. localtime_r( &t, &tEvent->sTS );// MT safe
  118. tEvent->m_UMSTS = tss;
  119. tEvent->m_UMSTS = tEvent->m_UMSTS * 1000 + tms;
  120. };
  121. tEvent->m_eClass = Class;
  122. CSTR tUUID = getUniqID_UUID(EventSeed_Counter++);
  123. if (tUUID)
  124. {
  125. sprintf(tEvent->m_UUID, "%s", tUUID);
  126. free(tUUID);
  127. }
  128. else
  129. {
  130. memset(tEvent->m_UUID, 0, 65);
  131. };
  132. tEvent->m_ref_UUID[0] = (char) 0; // malloc'ed struct: was left uninitialised without RefUUID
  133. tEvent->m_db_id = 0;
  134. tEvent->m_ref_id = 0;
  135. if (RefUUID)
  136. {
  137. snprintf(tEvent->m_ref_UUID, sizeof(tEvent->m_ref_UUID), "%s", RefUUID);
  138. };
  139. tEvent->m_eType = Type;
  140. tEvent->m_nDestinationNodeID = 0; // Broadcast
  141. tEvent->m_nSourceNodeID = SRC;
  142. tEvent->m_pEvtData = Data;
  143. if (Msg != NULL)
  144. {
  145. tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg) + 1);
  146. if (tEvent->m_pHumanReadableMsg)
  147. {
  148. strcpy(tEvent->m_pHumanReadableMsg, Msg);
  149. };
  150. }
  151. else
  152. {
  153. tEvent->m_pHumanReadableMsg = NULL;
  154. };
  155. };
  156. return tEvent;
  157. }
  158. EVENT_CONTAINER * createBasicTargetedEvent(uint64_t SRC, uint64_t DST, basicEventClassID Class, basicEventTypeID Type, char * RefUUID, char * Msg, void * Data, uint32_t tss, uint16_t tms)
  159. {
  160. EVENT_CONTAINER * tEvent;
  161. tEvent = (EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER));
  162. if (tEvent)
  163. {
  164. if (tss == 0)
  165. {
  166. time_t t = time(NULL);
  167. localtime_r( &t, &tEvent->sTS );// MT safe
  168. tEvent->m_UMSTS = getMilliseconds();
  169. }
  170. else
  171. {
  172. time_t t = (time_t) tss;
  173. localtime_r( &t, &tEvent->sTS );// MT safe
  174. tEvent->m_UMSTS = tss;
  175. tEvent->m_UMSTS = tEvent->m_UMSTS * 1000 + tms;
  176. };
  177. tEvent->m_eClass = Class;
  178. CSTR tUUID = getUniqID_UUID();
  179. if (tUUID)
  180. {
  181. sprintf(tEvent->m_UUID, "%s", tUUID);
  182. free(tUUID);
  183. }
  184. else
  185. {
  186. memset(tEvent->m_UUID, 0, 65);
  187. };
  188. tEvent->m_ref_UUID[0] = (char) 0; // malloc'ed struct: was left uninitialised without RefUUID
  189. tEvent->m_db_id = 0;
  190. tEvent->m_ref_id = 0;
  191. if (RefUUID)
  192. {
  193. snprintf(tEvent->m_ref_UUID, sizeof(tEvent->m_ref_UUID), "%s", RefUUID);
  194. };
  195. tEvent->m_eType = Type;
  196. tEvent->m_nDestinationNodeID = DST;
  197. tEvent->m_nSourceNodeID = SRC;
  198. tEvent->m_pEvtData = Data;
  199. if (Msg != NULL)
  200. {
  201. tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg) + 1);
  202. if (tEvent->m_pHumanReadableMsg)
  203. {
  204. strcpy(tEvent->m_pHumanReadableMsg, Msg);
  205. };
  206. }
  207. else
  208. {
  209. tEvent->m_pHumanReadableMsg = NULL;
  210. };
  211. };
  212. return tEvent;
  213. }