|
From: Daniel G. <go...@b1...> - 2010-06-25 08:25:08
|
On Friday 25 June 2010 08:05:36 pm Chris Frey wrote:
> It doesn't make sense to me yet.... unless the config gets unref'd twice
> later on?
>
> I'm confused with the _new() and the _set_config()... the
> _new() sets the ref to 1, and the _set_config() bumps it, so it seems
> that the returned config would have a ref of 2, even though it had just
> been created, and only the member holds a ref.
Ah, you're right - i was wrong.
The idea how this works is like this:
All osync_XXX_new() calls create "objects" with a refrence count of 1.
So on the first osync_XXX_unref() call the count decrease to 0 and the
"object" get freed.
Ref get increased as soon some other "object" or code starts using this
"object" as well.
In this case the reference get increased since the OSyncMember is going to use
OSyncPluginConfig*. Since it's no longer used within the
osync_member_get_config_or_default() function which allocated
OSyncPluginConfig* we have to decrease the reference once
osync_member_set_config() get called:
--- opensync/group/opensync_member.c (revision 6047)
+++ opensync/group/opensync_member.c (working copy)
@@ -294,6 +294,7 @@
goto error_free_config;
osync_member_set_config(member, config);
+ osync_plugin_config_unref(config);
osync_free(filename);
So if OSyncMember get freed the OSyncPluginConfig gets also freed if no other
function wants it shares on that object by increasing the ref-counts of this
pointer.
Does this make more sense now? :)
Thanks for finding this ...
Best Regards,
Daniel
--
Daniel Gollub Geschaeftsfuehrer: Ralph Dehner
Linux Consultant & Developer Unternehmenssitz: Vohburg
B1 Systems GmbH Amtsgericht: Ingolstadt
Mobil: +49-(0)-160 47 73 970 Handelsregister: HRB 3537
EMail: go...@b1... http://www.b1-systems.de
Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=get&search=0xED14B95C2F8CA78D
|