浏览代码

No, memcpy won't work here.

Eiyeron Fulmincendii 10 年之前
父节点
当前提交
49ba655288
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/piaf/Archive.cpp

+ 2 - 1
src/piaf/Archive.cpp

@@ -25,6 +25,7 @@ namespace
     {
     {
         T result = 0;
         T result = 0;
         uint8_t *data = (uint8_t *) ptr;
         uint8_t *data = (uint8_t *) ptr;
+        // No, memcpy isn't working here because endianness issues.
         for (unsigned i = 0; i < sizeof(T); i++)
         for (unsigned i = 0; i < sizeof(T); i++)
             // Writing each byte of value in order
             // Writing each byte of value in order
             result |= data[i] << (8 * (sizeof(T) - 1 - i));
             result |= data[i] << (8 * (sizeof(T) - 1 - i));
@@ -140,7 +141,7 @@ Archive::Archive(const char *filepath) : file(nullptr), entries(nullptr), files_
          // throw up; // haha
          // throw up; // haha
     }
     }
     
     
-    
+
     // At this point, the archive header looks unaltered and we finally can parse
     // At this point, the archive header looks unaltered and we finally can parse
     // and load the header.
     // and load the header.