changeset 44:2f5fd8a80636

merge
author Alain Mazy <am@osimis.io>
date Fri, 19 Mar 2021 17:37:56 +0100
parents 4c71c5e2edce (diff) 822e29256ffb (current diff)
children f10874e13d11
files
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Common/StoragePlugin.cpp	Fri Mar 19 12:13:18 2021 +0100
+++ b/Common/StoragePlugin.cpp	Fri Mar 19 17:37:56 2021 +0100
@@ -226,14 +226,13 @@
                                                      const char* uuid,
                                                      OrthancPluginContentType type)
 {
-  OrthancPluginMemoryBuffer64* buffer = nullptr;
-  OrthancPluginErrorCode result = StorageReadWhole(buffer, uuid, type);  // allocates the buffer but Orthanc won't delete it -> to delete ourselves
+  OrthancPluginMemoryBuffer64 buffer;
+  OrthancPluginErrorCode result = StorageReadWhole(&buffer, uuid, type); // will allocate OrthancPluginMemoryBuffer64
 
-  if (buffer != nullptr)
+  if (result == OrthancPluginErrorCode_Success)
   {
-    *size = buffer->size;
-    memcpy(*content, buffer->data, buffer->size);
-    OrthancPluginFreeMemoryBuffer64(OrthancPlugins::GetGlobalContext(), buffer);
+    *size = buffer.size;
+    *content = buffer.data; // orthanc will free the buffer (we don't have to delete it ourselves)
   }
 
   return result;