commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r786785 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/AbstractStructure.java test/org/apache/commons/runtime/TestStructure.java
Date Sat, 20 Jun 2009 10:02:47 GMT
Author: mturk
Date: Sat Jun 20 10:02:46 2009
New Revision: 786785

URL: http://svn.apache.org/viewvc?rev=786785&view=rev
Log:
Fix alignment calculation

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractStructure.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStructure.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractStructure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractStructure.java?rev=786785&r1=786784&r2=786785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractStructure.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractStructure.java
Sat Jun 20 10:02:46 2009
@@ -76,10 +76,9 @@
                     for (i = 0; i < count; i++) {
                         if (offset[i] == o.value()) {
                             fields[i] = f;
-                            int rsize = getElementSize(f, this);
-                            align     = Math.max(align, Math.min(8, rsize));
-                            esizes[i] = rsize;
+                            esizes[i] = getElementSize(f, this);
                             asizes[i] = getArrayElementLength(f, this);
+                            align     = Math.max(align, esizes[i]);
                         }
                     }
                 }
@@ -93,6 +92,12 @@
                 else
                     sizeof += esizes[i];
             }
+            if (align > Pointer.SIZEOF) {
+            	// Align to the pointer size except
+            	// for the structures which elements are not
+            	// larger the size of a pointer.
+            	align = Pointer.SIZEOF;
+			}
             sizeof = align(sizeof, align);
         }
     }

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStructure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStructure.java?rev=786785&r1=786784&r2=786785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStructure.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStructure.java Sat
Jun 20 10:02:46 2009
@@ -118,7 +118,7 @@
     {
         MyUStructure s = new MyUStructure();
         assertEquals("Fields",  4, s.count());
-        assertEquals("Sizeof", 32, s.sizeof());
+        assertEquals("Sizeof", 28, s.sizeof());
     }
 
     public void testOffset()



Mime
View raw message