Edoardo Luppi
11/06/2023, 10:57 AMmemscoped
block.
context (NativePlacement)
internal fun LPWSTR.toLatin1Buffer(): LPSTR {
val latin1BufferSize = WideCharToMultiByte(28591u /* ISO-8859-1 */, 0u, this@toLatin1Buffer, 0, null, 0, null, null)
val latin1buffer = allocArray<CHARVar>(latin1BufferSize)
WideCharToMultiByte(28591u /* ISO-8859-1 */, 0u, this@toLatin1Buffer, 0, latin1buffer, 0, null, null)
return latin1buffer
}
Oleg Yukhnevich
11/06/2023, 1:51 PMNativePlacement
to context receiver
and then, in this case you can accidentally be trapped in a situation when you create single MemScope
block for whole application - and so it will be never actually cleared
So, that' a good use case, but for me it's dangerous - but may be Im overreacting 🙂