For some reason, you can't get to that by clicking "code" on the header of this page. It is confusing.
In addition to moving the call to g_free, you need to remove the call to g_strdup at the bottom of foo_set_icon, so that icon_name is just a static string in the case where it is originally NULL. Otherwise you fix one leak and create another. This is the part of the patch I am talking about:
This problem is one of the reasons I deleted my patch.
Additionally, it might be a good idea to declare icon_name const in the foo_set_icon prototype to underscore the fact that foo_set_icon is not responsible for freeing it.
Some day, for the sake of consistency, it might be a good idea to make memory management for new_tip work the same way as for icon_name, so that in foo_set_icon() new_tip is const. There are a bunch of allocate-just-to-free cases that can be eliminated as well.
Is this the branch you are talking about?
https:/ /code.launchpad .net/~network- manager/ network- manager- applet/ ubuntu. head
For some reason, you can't get to that by clicking "code" on the header of this page. It is confusing.
In addition to moving the call to g_free, you need to remove the call to g_strdup at the bottom of foo_set_icon, so that icon_name is just a static string in the case where it is originally NULL. Otherwise you fix one leak and create another. This is the part of the patch I am talking about:
if (icon_name == NULL && layer == ICON_LAYER_LINK) { connection" );
icon_name = g_strdup ("nm-no-
}
This problem is one of the reasons I deleted my patch.
Additionally, it might be a good idea to declare icon_name const in the foo_set_icon prototype to underscore the fact that foo_set_icon is not responsible for freeing it.
Some day, for the sake of consistency, it might be a good idea to make memory management for new_tip work the same way as for icon_name, so that in foo_set_icon() new_tip is const. There are a bunch of allocate- just-to- free cases that can be eliminated as well.