[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libvir] RFC: safer memory allocation APIs with compile time checking



On Mon, Apr 28, 2008 at 10:41:46AM +0100, Mark McLoughlin wrote:
> On Mon, 2008-04-28 at 03:39 -0400, Daniel Veillard wrote:
> >   The proposal may help clean a lot of things, but VIR_REALLOC I don't
> > understand, what did i missed ?
> 
> Looks to me like VIR_REALLOC() would be a rarely used API and Dan just
> had a typo in the above example - it should have used VIR_REALLOC_N()

  ah, okay, I'm not the only one :-)

> I'm having difficulty thinking of how VIR_REALLOC() might be interesting
> - e.g. the highly contrived example below.
[...]
>    struct bar *get_bar(int i, int j)
>    {
>        struct bar *bar;
>        struct foo *foo;
> 
>        if (!(foo = get_foo(i)))
>            return NULL;
> 
>        bar = (struct bar *) foo;
> 
>        if (!VIR_REALLOC(bar)) {

  Seems to me it's usable only if you cast and grow to a different kind of
structure. i would rather ban code like this than explicitely allow it ;-)

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]