summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-10-02 17:00:47 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-10-06 19:00:41 +0000
commit96b9590dbeb20e000d9d9308bee2162b1101a7e0 (patch)
tree74a0f0bcfe735723ec03f6fb61276c2b10e9fd0a /examples
parent44081ded8a91e1d328109e13b8711b004cc88b70 (diff)
Refactor QSPI code on Windows
Current approach with passing of the array's data pointer to a Win API functions when the array is empty has potential danger. Because the data pointer is invalid, and if a Win API function tries to get access to this pointer then this can cause a crash or an UB. Still this does not happens, but nobody guarantees that this will be same in future. It is better to pre-allocate the array with some size (e.g. with the MAX_PATH size). In this case we can pass the data pointer without any problem. Besides, the Win API functions will return result with the first pass if the array size is sufficient; otherwise it returns ERROR_MORE_DATA error code and we can re-allocate the array with required size and to return a result in the second pass. We re-allocate the array with size more than required on some bytes with filling of the array with zeros. This allows us to convert it using QString::fromWCharArray() without specifying a size, and to remove the toStringAndTrimNullCharacter() function. Change-Id: I5976485286db4097514ea7b3a8adfc9a6a7cea4f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'examples')
0 files changed, 0 insertions, 0 deletions