hackz.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 07:43:42 +0000 (09:43 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 07:43:42 +0000 (09:43 +0200)
src/lib/cross.h
src/lib/cross_linux.cc
src/lib/cross_osx.cc
src/tools/dcpomatic_disk_writer.cc

index 64cb2e6b83f5bb8952fb1d2c4c10d629e7515385..ee7dd8a9e3214b39de06902b5224524c40f5ade8 100644 (file)
@@ -42,6 +42,8 @@ struct AVIOContext;
 
 extern void dcpomatic_sleep_seconds (int);
 extern void dcpomatic_sleep_milliseconds (int);
+extern void* dcpomatic_aligned_alloc (size_t size, size_t alignment);
+extern void dcpomatic_aligned_free (void* ptr);
 extern std::string cpu_info ();
 extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path);
 extern std::list<std::pair<std::string, std::string> > mount_info ();
index e17f188b9f8aacece46cfa29eb7cd884ab3d9797..27b87c2175711dc4dce72182d2128660ee172511 100644 (file)
@@ -74,6 +74,21 @@ dcpomatic_sleep_milliseconds (int ms)
        usleep (ms * 1000);
 }
 
+
+void*
+dcpomatic_aligned_alloc (size_t size, size_t alignment)
+{
+       return aligned_alloc (alignment, size);
+}
+
+
+void
+dcpomatic_aligned_free (void* ptr)
+{
+       free (ptr);
+}
+
+
 /** @return A string of CPU information (model name etc.) */
 string
 cpu_info ()
index e91d3df16c4a6e982bcd871aee39d3b2de77ed1e..f60e83b7ba0ded6831a0d2b8b2473ae923da97d2 100644 (file)
@@ -81,6 +81,21 @@ dcpomatic_sleep_milliseconds (int ms)
        usleep (ms * 1000);
 }
 
+
+void*
+dcpomatic_aligned_alloc (size_t size, size_t alignment)
+{
+       return aligned_alloc (alignment, size);
+}
+
+
+void
+dcpomatic_aligned_free (void* ptr)
+{
+       free (ptr);
+}
+
+
 /** @return A string of CPU information (model name etc.) */
 string
 cpu_info ()
index bd5ee81c2520ebff5b29d0fa40caa0c409f6c099..411d1ff5c6dc5d3f09d5bd6d56dc0b0440f90cff 100644 (file)
@@ -127,7 +127,7 @@ write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total
                throw CopyError (String::compose("Failed to open file %1", from.string()), 0);
        }
 
-       uint8_t* buffer = aligned_alloc (4096, block_size);
+       uint8_t* buffer = dcpomatic_aligned_alloc (block_size, 4096);
        if (!buffer) {
                throw bad_alloc();
        }
@@ -143,7 +143,7 @@ write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total
                if (read != this_time) {
                        fclose (in);
                        ext4_fclose (&out);
-                       free (buffer);
+                       dcpomatic_aligned_free (buffer);
                        throw CopyError (String::compose("Short read; expected %1 but read %2", this_time, read), 0);
                }
 
@@ -154,13 +154,13 @@ write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total
                if (r != EOK) {
                        fclose (in);
                        ext4_fclose (&out);
-                       free (buffer);
+                       dcpomatic_aligned_free (buffer);
                        throw CopyError ("Write failed", r);
                }
                if (written != this_time) {
                        fclose (in);
                        ext4_fclose (&out);
-                       free (buffer);
+                       dcpomatic_aligned_free (buffer);
                        throw CopyError (String::compose("Short write; expected %1 but wrote %2", this_time, written), 0);
                }
                remaining -= this_time;
@@ -174,7 +174,7 @@ write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total
 
        fclose (in);
        ext4_fclose (&out);
-       free (buffer);
+       dcpomatic_aligned_free (buffer);
 
        return digester.get ();
 }