[fpc-pascal] ContentData field size in FCGI_ContentRecor

Michael Van Canneyt michael at freepascal.org
Sat May 18 13:06:09 CEST 2019



On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

> I do not think so, because custfpcgi.pp is using many const and types declared in fastcgi.pp. removing it will cause rewrite in many parts of custfcgi units

You are right.

I should not try to answer questions based on memory alone :(

I did some digging and here is the long explanation:

The record definition is a formal record definition. 
The buffer was defined as 1024 bytes (1K), but this is completely arbitrary. 
It could have been [0..0], or [0..MaxInt].
Probably [0..0] would have been better. 
I will change it to that.

In practice a FCGI_ContentRecord is never used. A PFCGI_ContentRecord
(pointer to) is used to typecast an array of byte and extract the 
necessary header fields from the array.

It's a little like the typinfo structures: they describe memory layouts, but
some structures are just formal, for example

TVmtFieldTable =   record
         Count: Word;
         ClassTab: PVmtFieldClassTab;
         { should be array[Word] of TFieldInfo;  but
           Elements have variant size! force at least proper alignment }
         Fields: array[0..0] of TVmtFieldEntry;
       end;

The FCGI_ContentRecord definition should be seen in the same light: a formal
definition.

Michael.



More information about the fpc-pascal mailing list