CVS update: samba/source/rpc_server

Jean Francois Micouleau Jean-Francois.Micouleau at dalalu.fr
Sat Dec 22 20:59:31 EST 2001


On Sat, 22 Dec 2001, Simo Sorce wrote:

> I do not know if this would be a nice thing or a burden, but I was
> thinking to convert safe_free to support structs and any kind of data
> we want to define. Basically we only need to add an int field to any
> structure we alloc that will identify the structure type. and then
> make safe_struct_free() have a table of calls to call the correct free
> function. we will alloc the structure with a macro that set the
> correct reference. Do this sound useful? it would reduce greatly the
> number of free/alloc functions names to remember.


that's both a good and a bad idea. That's a good idea because you don't
have to remember all the names. That's a bad idea because you're making
SAFE_FREE() a complex function whereas you should keep that one simple.

If you want to write such a free() function, call it
safe_free_generic_struct(). And don't add an int to the struct to know
what struct type it is. Add a malloc_generic_struct() taking the size and
the struct type.

Or another solution would be to add to the struct a ptr to the free
function.

	J.F.






More information about the samba-cvs mailing list