Adds __reset method to Struct and Table (#4966)

This allow recycling/pooling instances without leaking ByteBuffers, by
providing a mechanism to reset instance to newly constructed state.
This commit is contained in:
Jason Neufeld
2018-10-03 12:09:30 -07:00
committed by Wouter van Oortmerssen
parent 7a43775661
commit f85af46262
2 changed files with 26 additions and 0 deletions

View File

@@ -292,6 +292,18 @@ public class Table {
}
return len_1 - len_2;
}
/**
* Resets the internal state with a null {@code ByteBuffer} and a zero position.
*
* This method exists primarily to allow recycling Table instances without risking memory leaks
* due to {@code ByteBuffer} references. The instance will be unusable until it is assigned
* again to a {@code ByteBuffer}.
*/
public void __reset() {
bb = null;
bb_pos = 0;
}
}
/// @endcond