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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a4d2751f9487bd38 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-07 02:27:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!peer2.news.opaltelecom.net!newsfeed.freenet.de!newsfeed.r-kom.de!eusc.inter.net!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Real data for a change in the assignment operators and Bounded_String discussions. Date: Mon, 7 Jul 2003 09:27:11 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <3F04F778.5090305@attbi.com> NNTP-Posting-Host: d2-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1057570031 15640 134.91.1.15 (7 Jul 2003 09:27:11 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Mon, 7 Jul 2003 09:27:11 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/831)) Xref: archiver1.google.com comp.lang.ada:40100 Date: 2003-07-07T09:27:11+00:00 List-Id: Hyman Rosen wrote: : :> (I can imagine trying to write that code in C, with mallocs, frees, : > searches for nul (strlen) and copies all over the place. Ouch!) : : Well, let's see (error checking left out): Indeed ;-) The program has a leak. Adding int main() { /* make sure this file exists, otherwise you might get a segmentation fault */ char* TEST_FILE = "test.file"; char* _1st_line = 0; while (1) _1st_line = first_line_of_file(TEST_FILE); fputs(_1st_line, stdout); } and a few "(char*)realloc(...)" to first_line_of_file(). georg@strudel:/tmp$ gcc -o whole whole.c georg@strudel:/tmp$ ls -l test.file -rw-r--r-- 1 georg staff 0 Jul 7 10:24 test.file georg@strudel:/tmp$ ./whole