[Info-vax] calloc fails with access violation
JF Mezei
jfmezei.spamnot at vaxination.ca
Mon Aug 24 15:01:49 EDT 2009
Jose Cuevas wrote:
> In the above code I can printf the pointer sIn and do a strlen without
> problems,
strlen counts bytes until it encounters a null character. It may run
fine but return some gigantic number.
The COBOL strings passed do not contain a null to indicate end of
string. you "strlen" would work only because somewhere in accessible
memory of the process, the strlen would encounter a null character.
The C program must either be told explicitely (hardcoded or though an
argument) the size of a string, or you must pass the COBO strings BY
DESCRIPTOR and have the C program expect a descriptor structure at which
point it can examine the structure to find the length of the string
(allocated length) and the address where it is located.
More information about the Info-vax
mailing list