allocate(length: Integer64) updating;
The allocate method of the JadeBytes class allocates virtual storage on the receiver to hold binary content up to the specified length. The amount of virtual storage is specified by the value of the length parameter.
Use the allocate method to build binary content in a piece-wise manner with the putData or atPut methods. When data is loaded sequentially by using the appendData method or in its entirety by using the loadFromFile method, there is no need to allocate storage in advance.
Use the allocate method only on an empty JadeBytes object. If the JadeBytes object has a defined length greater than zero (0), use the grow method to increase the length (the amount of virtual storage).
The following example shows the use of the allocate method.
vars bytes : JadeBytes; begin create bytes; bytes.allocate(5); bytes.add(#4A.Byte); write bytes.getContent; // Writes "?????J", where ? is a null byte epilog delete bytes; end;
An invalid size specified in the length parameter (for example, less than zero (0) or greater than the maximum instance size of approximately 1,019G bytes) raises an exception.