Guileful BSTR strings

Let’s talk about one more nasty data type – BSTR (Basic string or binary string).

The fragment is taken from VirtualBox project. The code contains an error that analyzer diagnoses in the following way: V745 A ‘wchar_t *’ type string is incorrectly converted to ‘BSTR’ type string. Consider using ‘SysAllocString’ function. Continue reading

Avoid adding a new library to the project

Suppose you need to implement an X functionality in your project. Theorists of software development will say that you have to take the already existing library Y, and use it to implement the things you need. In fact, it is a classic approach in software development – reusing your own or others’ previously created libraries (third-party libraries). And most programmers use this way. Continue reading

If something strange is happening to your PC, check its memory

A typical situation – your program is not working properly. But you have no idea what’s going on. In such situations we recommend not rushing to blame someone, but focus on your code. In 99.99% of cases, the root of the evil is a bug that was brought by someone from your development team. Very often this bug is really stupid and banal. So go ahead and spend some time looking for it! Continue reading

Use a prefix increment operator (++i) in iterators instead of a postfix (i++) operator

The fragment is taken from the Unreal Engine 4 project. Ineffective code is detected by the following diagnostic: V803 Decreased performance. In case ‘itr’ is iterator it’s more effective to use prefix form of increment. Replace iterator++ with ++iterator.

Continue reading