mk-soft wrote: Mon Dec 19, 2022 4:33 pm
That is not what was meant. I also read it wrong at first. The point is that CopyMemoryString is not written over the available memory.
Yes, that's more or less it. CopyMemoryString doesn't provide any control over attempting to copy the longer string into a shorter memory buffer, such as when putting data into a fixed-sized blocks. There's a subtle requirement here, which is that it should still terminate on null (which it already does), but also provide a size parameter, which so many of the the other 'Memory' functions already provide (please see list below). CopyMemory is okay to a point, but it doesn't terminate on nulls.
I wrote my code using PokeS() from the start, but I'm just aware that it isn't as fast as direct memory copying. So this is just a feature suggestion. Out of interest, from the list of 'Memory' functions, nine of them already provide a 'Size' parameter, but CopyMemoryString is the exception that doesn't provide it. Even its very close cousin CompareMemoryString() has a size parameter. Below is the list where 'Size' is provided already. I know some of them are obvious because Size is necessary for them, but it's just useful to have an idea of those where the size has been provided...
Code: Select all
AllocateMemory()
CompareMemory()
CompareMemoryString()
CopyMemory()
FillMemory()
MoveMemory()
PeekS()
PokeS()
ReAllocateMemory()