[Info-vax] calloc fails with access violation
Jose Cuevas
jcuevas at mac.com
Tue Aug 25 16:23:15 EDT 2009
I wrote some new test code, using plain C string functions and char *
as arguments and the other using descriptors thanks to the sample
posted by Bob Gezelter. I ran the test cobol and c code with the same
1000 records crashing my old code. I found that:
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.
I started re-factoring the code one piece at a time and testing each
element by it self. I found that my code is crashing at a point I have
a string that I just malloced, I can printed, I can get its size. This
is a c-string not a cobol string. Then when I pass this same char * as
argument to another c function. In the other function I can print it,
I can get it size. As soon as I try to alloc it craches with an access
violation in:
char *encoded=calloc(sz*2,sizeof(char)); int i=0;
I'll play with it more, and I will try the other suggestions also.
More information about the Info-vax
mailing list