#define HAVE_EXIV2_ERROR_CODE
#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#if EXIV2_TEST_VERSION(0,27,0)
#define EXV_PACKAGE "exiv2"
#include <glib.h>
-#include "main.h"
#include "exif.h"
+#include "debug.h"
#include "filedata.h"
#include "filefilter.h"
#include "misc.h"
+#include "options.h"
#include "ui-fileops.h"
#if EXIV2_TEST_VERSION(0,28,0)
Exiv2::PreviewImage image = pm.getPreviewImage(*pos);
- Exiv2::DataBuf buf = image.copy();
-
-#if EXIV2_TEST_VERSION(0,28,0)
- *data_len = buf.size();
- auto b = buf.data();
- buf.reset();
- return b;
-#else
- std::pair<Exiv2::byte*, long> p = buf.release();
-
- *data_len = p.second;
- return p.first;
-#endif
+ // Let's not touch data_len until we finish copy.
+ // Just in case we run into OOM.
+ size_t img_sz = image.size();
+ auto* b = new Exiv2::byte[img_sz];
+ std::copy_n(image.pData(), img_sz, b);
+ *data_len = img_sz;
+ return b;
}
return nullptr;
}
}
}
-void exif_free_preview(guchar *buf)
+void exif_free_preview(const guchar *buf)
{
- delete[] static_cast<Exiv2::byte*>(buf);
+delete[] static_cast<const Exiv2::byte*>(buf);
}
#endif
}
-void exif_free_preview(guchar *buf)
+void exif_free_preview(const guchar *buf)
{
GList *work = exif_unmap_list;