Features of the mql5 language, subtleties and tricks - page 217
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How do I now (b3110) zero a complex structure?
Constructor with zeroing.
And if you want to zero in progress, there is also an additional method for doing so:
Constructor with zeroing.
And if you want to zero it while working, then additional method for this:
I would like a universal method, as ZeroMemory once allowed.
Consider that I have changed - now I check the 1st term for x[i].i == 0 (previously the condition was x[i].x == 0.0)
Result: false
And with ZeroMemory - true.
Thanks, fixed it.
Forum on trading, automated trading systems and trading strategies testing
Peculiarities of mql5, tips and tricks
mktr8591, 2021.08.12 19:43
I set a pending limit. Then I change it manually and by script and ORDER_TIME_SETUP changes.
Example of what changes.
Setting log.
ORDER_TIME_SETUP is changed. Bug?
I would like a universal way, as ZeroMemory once allowed.
And who will release the buffer in string? ZeroMemory is essentially an analogue of this.
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366920(v=vs.85)
No destructors will be called. Correspondingly, the buffer pointer will be cleared in string, while the buffer itself will be leaked. Direct work with memory is like a minefield - if you lose vigilance, that's it)))
Here is an example of leakage in your case:
The object no longer possesses a pointer to the buffer, but the buffer itself has "leaked".
PS. Fuck it not POD types to zero through memset and ZeroMemory
PS. Well its not a POD type zeroing via memset and ZeroMemory
Haven't tested it, but I think the string buffer gets zeroed.
I haven't checked, but I think the string buffer is being reset.
Why would it reset?)))
It's all grown-up, as it should be)))
UPD: t1, t2 with their output, so that the compiler wouldn't over-optimize the whole thing)
UPD2: they may call delete for the buffer, but I can't figure out how to do it in a case where string is inside the structure
UPD3: although it's written in help, it's called for it personally, so it should free buffer, I hope, that by pointer to freed memory already read data.
Why would he reset?))
It would be good to see
Print(GetAddress(a.a));
Before and after.
It would be good to see
Before and after.
As it should be. In the first case the memory address, in the second 0
Why would he reset?)))
Everything here is mature, as it should be)))
UPD: t1, t2 with their output, so that the compiler wouldn't over-optimize the whole thing)
UPD2: they may call delete for the buffer, but I can't figure out how to do it in a case where string is inside the structure
UPD3: although it's written in help, it's called for it personally, so it should free the buffer, I hope it's by a pointer to the freed memory already read data.
In principle, everything there should be quite trivial in implementation)