[Info-vax] calloc fails with access violation
Richard Maher
maher_rj at hotspamnotmail.com
Mon Aug 24 20:00:12 EDT 2009
"John Reagan" <johnrreagan at earthlink.net> wrote in message
news:266dnSnvNdUVgA7XnZ2dnUVZ_v-dnZ2d at earthlink.com...
>
> <VAXman- @SendSpamHere.ORG> wrote in message
> news:00A90863.E6048EBC at SendSpamHere.ORG...
> > In article
> > <7447c5b2-7ae5-488d-a2a8-099088796bd2 at r42g2000yqj.googlegroups.com>,
Jose
> > Cuevas
> >
> > COBOL does not, AFAIK, create NULL terminated strings when passing data
by
> > reference. In fact, I have written many Macro32 routines for people
using
> > COBOL and I've not seen a null terminated string. You might see data
with
> > a null but that is NOT guaranteed. John Reagan, compiler droogie, may
be
> > lurking and can better address this.
> >
>
> No, I don't think it does. However, Hein or Richard will certainly be
able
> to offer real examples. They've forgotten more about COBOL than I know
[but
> then again, I haven't tried very hard to learn COBOL :) ]
>
"Null-terminated Strings" God help us :-(
I'm not sure what the OP intended but COBOLs string passing by default is
just a reference to a chunk of memory of an agreed maximum size. By
Descriptor can be useful (more so for languages like BASIC than C I guess)
but if you want to null-terminate then just: -
01 my_asciz.
03 some_max pic x(15).
03 pic x(1) value low-value.
or there's: -
01 my_varchar.
03 strlen pic 9(4) comp.
03 some_max pic x(15).
or :-
call "str$trim" using by descriptor some_max, some_max
by reference true_len
giving sys_status.
call "c_rubbish" using by descriptor some_max(1:true_len).
> John
Cheers Richard Maher
>
>
PS. is calloc "cancel alloc" or "character alloc"? Not sure what you'd be
cancelling/freeing but at the end of the day COBOL just gives you a pointer
to a chunck of memory whose format size and content you have to have some
convention for. It's as straight forward as it gets and very little in the
way of Stack,
More information about the Info-vax
mailing list