[parted-devel] parted port to FreeBSD

Håkon Løvdal hlovdal at gmail.com
Wed Apr 26 13:52:59 UTC 2006


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)
                ...
        }
        ...

Answer (http://www.rot13.com/): Vs ernyybp snvyf vg ergheaf AHYY,
naq jvgu pbqr yvxr guvf lbh gura unir ybfg lbhe ersrerapr gb gur bevtvany
nyybpngrq zrzbel. Ohg gur NCV _ernyyl_ vaivgrf gb jevgr pbqr guvf jnl.

Speaking of APIs, Joel Spolsky has some interesting thoughts on
"Making Wrong Code Look Wrong" at http://joelonsoftware.com/articles/Wrong.html.

BR Håkon Løvdal


More information about the parted-devel mailing list