Hi!
According to this part of documentation:
the following code mustn't reallocate memory:void QByteArray::reserve ( int size )
Attempts to allocate memory for at least size bytes. If you know in advance how large the byte array will be, you can call this function, and if you call resize() often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QByteArray will be a bit slower.
The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the byte array, call resize().
What is wrong?Qt Code:
QByteArray array; array.reserve(1024); array.resize(1024); assert(array.capacity() == 1024); // ok array.resize(120); assert(array.capacity() == 1024); // failTo copy to clipboard, switch view to plain text mode
Thank you.
Bookmarks