#1 2025-08-20 22:09:38

DawgBuddy
Member
Registered: 2025-08-20
Posts: 2

TSynTempBuffer used in RunCommandWin question

Hi ab, whenever I need ideas on how to do something I always grep your mormot2 source. Today I was wanting different ideas on using the ReadFile api and I found how you used it in mormot.core.os.windows.inc in the RunCommandWin function. However, I'm confused on how the TSynTempBuffer var is being used with ReadFile.

var tmp: TSynTempBuffer;

Win32Check(ReadFile(rd, tmp, pending, n, nil));

I didn't see a custom ReadFile function in your code so should that be tmp.buf which is how it's used in other lines or am I not seeing something correctly?

Thanks for all the code you've coded!

Offline

#2 2025-08-21 15:53:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,153
Website

Re: TSynTempBuffer used in RunCommandWin question

Here TSynTempBuffer is used as a 4KB raw buffer on stack.
If you look at the code, its members like buf or len are just not used.

I understand it may be confusing.
I have made a whole code review to use TBuffer4K instead - which seems more explicit:
https://github.com/synopse/mORMot2/commit/a0126f0da

Offline

#3 Yesterday 01:41:11

DawgBuddy
Member
Registered: 2025-08-20
Posts: 2

Re: TSynTempBuffer used in RunCommandWin question

Oh that's neat, never seen that done before and I had to find out how it worked. Thanks for your reply.

Offline

Board footer

Powered by FluxBB