[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU-COBOL] Re: idiotproof? (fwd)



--
-->>Matthew Fischer wrote :>
>
>>> I have never written a library before, so I dont really know how
>>>idiot proof to make this.  I mean, if you call my truncation function and
>>>tell it you want to chop the number down to -129182 digits, it will say
>>>f_trunc:: Couldn't malloc -129182 bytes of memory.

If we are writing Cobol (as opposed to something that looks like Cobol) all
memory should be allocated at compile time.  The only run-time allocation
should be made by the loader and the Cobol run-time initialization routines.
Every data element used by the program (except FD) should be exist in the
load module.  This should include temporary and scratch pad areas.  At
run-time, the library functions should be passed a pointer to this
pre-allocated storage along with information as to the type and size of the
data.  The only malloc that a cobol program should call is to allocate
working storage (as a block) and internal workspace (as a block) at program
initialization.

At run time, if the function can't handle the data area passed to it (e.g.,
divide by zero), it should format the data in the storage areas passed to it
in ascii and hex to STDERR and call the cleanup termination routines.

Glen


--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to gnu-cobol@acm.cs.umr.edu with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@acm.cs.umr.edu.