From: Georg Bauhaus <sb463ba@d2-hrz.uni-duisburg.de>
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)
Date: 2003-07-07T09:27:11+00:00 [thread overview]
Message-ID: <bebedf$f8o$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: fF6Oa.14365$Ha.10004@nwrdny02.gnilink.net
Hyman Rosen <hyrosen@mail.com> 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
next prev parent reply other threads:[~2003-07-07 9:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-04 3:41 Real data for a change in the assignment operators and Bounded_String discussions Robert I. Eachus
2003-07-05 1:29 ` Inc (was: Real data for a change in the assignment operators and Bounded_String discussions. ) Alexander Kopilovitch
2003-07-07 21:31 ` Gautier Write-only
2003-07-07 21:35 ` Inc (was: Real data for a change in the assignment operators and Larry Kilgallen
2003-07-08 3:53 ` Gautier Write-only
2003-07-08 20:50 ` Alexander Kopilovitch
2003-07-07 21:42 ` Inc (was: Real data for a change in the assignment operators and Bounded_String discussions. ) Vinzent Hoefler
2003-07-08 4:04 ` Gautier Write-only
2003-07-07 4:27 ` Real data for a change in the assignment operators and Bounded_String discussions Hyman Rosen
2003-07-07 9:27 ` Georg Bauhaus [this message]
2003-07-07 9:41 ` Georg Bauhaus
2003-07-07 14:29 ` Hyman Rosen
2003-07-07 17:29 ` Georg Bauhaus
2003-07-07 19:01 ` Hyman Rosen
2003-07-07 15:49 ` Robert I. Eachus
2003-07-07 13:46 ` Hyman Rosen
2003-07-07 16:03 ` Robert I. Eachus
2003-07-07 18:52 ` Hyman Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox