@@ -286,15 +286,15 @@ protected void useMemory(Pointer m) {
286
286
}
287
287
288
288
/** Set the memory used by this structure. This method is used to
289
- * indicate the given structure is nested within another or otherwise
290
- * overlaid on some other memory block and thus does not own its own
291
- * memory.
289
+ * indicate the given structure is based on natively-allocated data,
290
+ * nested within another, or otherwise overlaid on existing memory and
291
+ * thus does not own its own memory allocation .
292
292
*/
293
293
protected void useMemory (Pointer m , int offset ) {
294
- // Invoking calculateSize() here is important when this method is
295
- // invoked from the ctor, to ensure fields are properly scanned and
296
- // allocated
297
294
try {
295
+ // Ensure our memory pointer is initialized, even if we can't
296
+ // yet figure out a proper size/layout
297
+ this .memory = m .share (offset );
298
298
if (size == CALCULATE_SIZE ) {
299
299
size = calculateSize (false );
300
300
}
@@ -923,7 +923,8 @@ private LayoutInfo deriveLayout(boolean force, boolean avoidFFIType) {
923
923
throw new IllegalArgumentException ("This VM does not support read-only fields (field '"
924
924
+ field .getName () + "' within " + getClass () + ")" );
925
925
}
926
- // In J2SE VMs, this allows overriding the value of final fields
926
+ // In J2SE VMs, this allows overriding the value of final
927
+ // fields
927
928
field .setAccessible (true );
928
929
}
929
930
structField .field = field ;
0 commit comments