[Gllug] Off Topic: C File Descriptors
salsaman at xs4all.nl
salsaman at xs4all.nl
Sun Mar 9 22:50:09 UTC 2008
On Sun, March 9, 2008 23:26, Nix wrote:
> On 8 Mar 2008, Richard Jones said:
>
>> On Fri, Mar 07, 2008 at 02:41:47AM +0100, salsaman at xs4all.nl wrote:
>>> something like this (untested, YMMV) should do it:
>> [appallingly bad example of C snipped]
>
> Oh come on, he allocated a whole 512 bytes for the filename and only had
> four coredump-inducing bugs, two misunderstandings of the nature of
> dynamic memory allocation,, two useless uses of memset() and two blocks
> of cut-and-pasted code. I've seen *much* worse.
Say what ? 512 is the maximum path length on Linux, I don't see where the
bugs were or how I misunderstood dynamic memory allocation (I presume you
mean the sprintf). The memset is needed because readlink() does not append
a null byte - check the manpage.
Two blocks of similar code yes, I was writing it quick otherwise I might
have made an inline function.
Gabriel.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list