From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: Real data for a change in the assignment operators and Bounded_String discussions.
Date: Mon, 07 Jul 2003 09:46:51 -0400
Date: 2003-07-07T09:46:51-04:00 [thread overview]
Message-ID: <1057585611.821825@master.nyc.kbcfp.com> (raw)
In-Reply-To: <bebedf$f8o$1@a1-hrz.uni-duisburg.de>
Georg Bauhaus wrote:
> : Well, let's see (error checking left out):
> Indeed ;-)
The Ada program didn't check for sucessful file opens,
and didn't check for Storage_Error, so I did the same
in my C code.
> The program has a leak.
Your program has a leak. The C version necessarily
differs from the Ada version in that it must allocate
memory on the heap, so the returned pointer must be
freed by the caller.
> while (1)
> _1st_line = first_line_of_file(TEST_FILE);
> fputs(_1st_line, stdout);
Instead,
while (1)
{
_1st_line = first_line_of_file(TEST_FILE);
fputs(_1st_line, stdout);
free(_1st_line);
}
> and a few "(char*)realloc(...)" to first_line_of_file().
Unnecessary in C code, provided you include the correct
header file. Realloc returns a void*, which in C converts
to any other pointer without a cast.
next prev parent reply other threads:[~2003-07-07 13:46 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
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 [this message]
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