refactor get public data, to be slightly easier to use on callee side
[clinton/Smoothieware.git] / src / libs / PublicData.cpp
index 3307d00..28401dc 100644 (file)
@@ -4,7 +4,9 @@
 
 bool PublicData::get_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data) {
     PublicDataRequest pdr(csa, csb, csc);
-    pdr.set_data_ptr(data); // the caller may have put a placeholder for the returned data here
+    // the caller may have created the storage for the returned data so we clear the flag,
+    // if it gets set by the callee setting the data ptr that means the data is a pointer to a pointer and is set to a pointer to the returned data
+    pdr.set_data_ptr(data, false);
     THEKERNEL->call_event(ON_GET_PUBLIC_DATA, &pdr );
     if(pdr.is_taken() && pdr.has_returned_data()) {
         // the callee set the returned data pointer