[ros-general] How can I copy code from ReactOS to mingw-w64?
Thomas Faber
thomas.faber at reactos.org
Sat Apr 9 14:23:16 UTC 2022
Hi again,
On 2022-03-17 00:00, LIU Hao wrote:
> 1) According to MS docs [1], `ConvertBSTRToString()` returns a string
> that the user must delete via `delete[]`, so why is the returned
> buffer allocated via `::operator new()`, instead of `new char[...]`?
I think this only makes a difference in terms of how
constructors/destructors are called, so shouldn't matter for an array of
chars.
I'm not sure whether there's any particular advantage here to calling
the operator directly rather than the more obvious new[]. So it could
make sense to change it.
> 2) `::operator new()` throws an exception on failure and never returns
> a null pointer. This makes the null check about its return value
> unnecessary. Is it supposed to be `::new(::std::nothrow) char[...]`?
> Or do we ignore such circumstances?
I think this is a bug and we should indeed be calling the nothrow operator.
Best,
Thomas
More information about the Ros-general
mailing list