From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,133de21eb82605b,start X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: How do functions return unbounded arrays? Date: 1998/06/14 Message-ID: <358444BA.757121D8@cl.cam.ac.uk>#1/1 X-Deja-AN: 362630763 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-06-14T00:00:00+00:00 List-Id: One of the things that still puzzles me about Ada is: how do compilers implement functions such as "&" that return variable length strings or arrays. To get such a functionality under C, I would have to malloc() the memory for a String in the C function and then I am left with the question of when to free this memory. Does an Ada function such as "&" (concatenation of arrays) allocate secretly memory on the heap to get a space to store the result? If yes, when exactly is this memory deallocated? Are there Ada programs that cause a heap overflow just by calling "&" in a long loop and where this danger of a heap overflow is not explicit in the program text as no allocator is visible? In other words, are there any safety (heap overflow) risks associated with functions like "&"? Is there a good paper that describes those things that silently go on between the lines of an Ada program and that still keep me from getting the warm fuzzy C programmer feeling that I really know what exactly is going on when my code executes? Also, is there any documentation around that describes the interface that GNAT expects from the run-time library, i.e. whatever one would need in order to write a new GNAT runtime library with all the tasking, memory management, etc. (Again, just to get the feeling that I know what is going on behind the scenes.) Markus -- Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK email: mkuhn at acm.org, home page: