Ross McFarland wrote:
On Thu, Aug 27, 2009 at 3:20 PM, Eric Day<[email protected]> wrote:
On Wed, Aug 26, 2009 at 09:44:52PM -0700, Ross McFarland wrote:
It's not uncommon for libraries to do the memory management for
you, and like I said, I wanted to make it easy for both types of
users.
perhaps a better approach would be to do:
drizzle_con_st *drizzle_con_new (drizzle_return_t * ret, <params>);
drizzle_return_t drizzle_con_initialize (drizzle_con_st * con, <params>);
and drizzle_con_new would just be:
drizzle_con_st *drizzle_con_new (drizzle_return_t * ret, <params>)
{
drizzle_con_st * con = malloc (sizeof (drizzle_con_st));
// error handle
*ret = drizzle_con_initialize (con, <params>);
return con;
}
that lets people who want to manage memory do it and people who want it done for
them have it done for them and neither has to deal with the other's path.
I thought about this approach initially and decided against it since
it was an extra function for every object. I'm not opposed to this and
will add this to a list of items to send out to the mailing list about.
cool.
Personally I don't like to expose the content of my structures through
the API, because it makes it harder to maintain binary compatibility. It
is easy to remember to update the library interface number when you add
/ remove functions, but it is really easy to forget when you just add /
remove one member from a structure in an area it isn't obvious it would
impact the external interface ... If you want to pass in the memory
area, you should at least also pass along the size so the library can
check for the correct size...
Cheers,
Trond
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp