int mu_folder_set_authority (mu_folder_t folder, mu_authority_t authority) { if (folder == NULL) return EINVAL; if (folder->authority) mu_authority_destroy (&folder->authority, folder); folder->authority = authority; return 0; }
static PyObject * api_authority_destroy (PyObject *self, PyObject *args) { PyAuthority *py_auth; if (!PyArg_ParseTuple (args, "O!", &PyAuthorityType, &py_auth)) return NULL; mu_authority_destroy (&py_auth->auth, NULL); return _ro (Py_None); }
/* The folder is destroy if it is the last reference. */ void mu_folder_destroy (mu_folder_t *pfolder) { if (pfolder && *pfolder) { mu_folder_t folder = *pfolder; int destroy_lock = 0; mu_monitor_t monitor = folder->monitor; mu_monitor_wrlock (monitor); /* Check if this the last reference for this folder. If yes removed it from the list. */ mu_monitor_wrlock (&folder_lock); folder->ref--; /* Remove the folder from the list of known folder. */ if (folder->ref <= 0) mu_list_remove (known_folder_list, folder); /* If the list is empty we can safely remove it. */ if (mu_list_is_empty (known_folder_list)) mu_list_destroy (&known_folder_list); mu_monitor_unlock (&folder_lock); if (folder->ref <= 0) { mu_monitor_unlock (monitor); destroy_lock = 1; /* Notify the observers. */ if (folder->observable) { mu_observable_notify (folder->observable, MU_EVT_FOLDER_DESTROY, folder); mu_observable_destroy (&folder->observable, folder); } if (folder->_destroy) folder->_destroy (folder); mu_monitor_wrlock (monitor); if (folder->authority) mu_authority_destroy (&folder->authority, folder); if (folder->url) mu_url_destroy (&folder->url); if (folder->property) mu_property_destroy (&folder->property); free (folder); } mu_monitor_unlock (monitor); if (destroy_lock) mu_monitor_destroy (&monitor, folder); *pfolder = NULL; } }