A common convention in Upstart+NIH is for functions to accept a parent pointer as in the following example:
Foo *make_foo (const void *parent) __attribute__ ((malloc));
Foo * make_foo (const void *parent) { Foo *foo = nih_new (parent, Foo);
/* ... */
return foo; }
But, if I'm understanding this correctly (?), using the malloc attribute here is also invalid iff parent != NULL since nih_new() ultimately saves the value of foo to the parents context before returning the address of foo.
A common convention in Upstart+NIH is for functions to accept a parent pointer as in the following example:
Foo *make_foo (const void *parent) __attribute__ ((malloc));
Foo *
make_foo (const void *parent)
{
Foo *foo = nih_new (parent, Foo);
/* ... */
return foo;
}
But, if I'm understanding this correctly (?), using the malloc attribute here is also invalid iff parent != NULL since nih_new() ultimately saves the value of foo to the parents context before returning the address of foo.