[parted-devel] parted port to FreeBSD
Viktor Vasilev
viktor.vasilev at stud.tu-darmstadt.de
Wed Apr 26 14:42:34 UTC 2006
Quoting Håkon Løvdal <hlovdal at gmail.com>:
> On 26/04/06, Viktor Vasilev <viktor.vasilev at stud.tu-darmstadt.de> wrote:
> > On Wednesday 26 April 2006 10:37 leslie.polzer at gmx.net wrote:
> > > This is expected behaviour -- see realloc(3).
> >
> > I'll try to catch up on the realloc semantics :)
>
> This is maybe slightly offtopic, but realloc is - for good reasons -
> thoroughly
> discussed and used as an example of a very poor API by Steve Maguire
> in his book "Writing Solid Code".
>
> Realloc is a bloated do-everything function with an API that invites to
> making errors. Test: what is wrong with the following code?
>
> ...
> ptr = realloc(ptr, 200)
> if (ptr == NULL)
> ...
> }
> ...
Yes, this example is also present in "The Practice Of Programming" by
Brian W. Kernighan and Rob Pike. The original code (parted/table.c:
table_render_row) is wrong in this aspect:
*s = realloc (*s, newsize);
Maybe one could use libparted/libparted.c:ped_realloc to be consistent.
What I find irritating is that this code obviously runs smooth on linux
as the screen corruption can't be overlooked.
Cheers,
Vik
More information about the parted-devel
mailing list