[Info-vax] calloc fails with access violation

sapienzaf sapienza at noesys.com
Tue Aug 25 21:51:17 EDT 2009


On Aug 25, 4:23 pm, Jose Cuevas <jcue... at mac.com> wrote:
> That using char * as arguments in C when using "BY REFERENCE" in cobol
> does not make a difference at all. All strings returned the same size,
> and I was able to treat them a null-strings in the C side. That makes
> think that the runtime is doing the conversion for me.  I tested every
> standard library in C that I know depends on NULL and they work, I
> loop tru the pointer and it has a NULL.
>

Here is another Cobol sample, where the strings are defined at the 01
level.  I increased the size of the strings so that they are using
complete quadwords.  Notice that the C subroutine prints the wrong
string length.  Again, Cobol does not null-terminate its strings.

       identification division.
       program-id. cobmain.

       data division.
       working-storage section.
       01  string_a    pic x(24) value spaces.
       01  string_b    pic x(24) value spaces.
       01  zerobyte    pic s9(4) comp value zero.

       procedure division.
       main-program section.
       do-it.
            call 'ccstub' using string_a.
            call 'ccstub' using string_b.

            stop run.

$ cob /ansi cobmain
$ cc ccstub
$ link cobmain, ccstub
$ run cobmain
Length=49
Length=25



More information about the Info-vax mailing list