Re: RFC: safer memory allocation APIs with compile time checking

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

 



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@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]