Browse Source

req_padding(): Always align to 4 bytes.

Ioannis Koutras 13 years ago
parent
commit
dc8e286c9a
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/other.c

+ 8 - 0
src/other.c

@@ -19,6 +19,8 @@
 #include <pthread.h>
 #include <pthread.h>
 
 
 size_t req_padding(size_t size) {
 size_t req_padding(size_t size) {
+    size_t align;
+
     if(size <= 32)
     if(size <= 32)
         return 32;
         return 32;
     if(size <= 64)
     if(size <= 64)
@@ -27,6 +29,12 @@ size_t req_padding(size_t size) {
         return 128;
         return 128;
     if(size <= 256)
     if(size <= 256)
         return 256;
         return 256;
+
+    align = size % 4;
+    if(align != 0) {
+        size += 4 - align;
+    }
+
     return size;
     return size;
 }
 }