memcpy(&to_free, &ptr, sizeof(to_free));
- talloc_unlink(talloc_parent(ptr), to_free);
+ if (talloc_reference_count(to_free) == 0) {
+ talloc_free(to_free);
+ } else {
+ talloc_unlink(talloc_parent(ptr), to_free);
+ }
}
/** Add a NULL pointer to an array of pointers
memcpy(&to_free, &cd->data, sizeof(to_free));
- if (cd->free) talloc_free(to_free);
+ if (cd->free) talloc_decrease_ref_count(to_free); /* Also works OK for non-reference counted chunks */
return 0;
}
* dl *MUST* be set to NULL, so that if the server decides to
* load more modules, the tree is recreated.
*/
- if (rbtree_num_elements(dl_loader->tree) == 0) {
- ERROR("Freeing dl loader");
- TALLOC_FREE(dl_loader);
- }
+ if (rbtree_num_elements(dl_loader->tree) == 0) TALLOC_FREE(dl_loader);
return 0;
}
CONF_SECTION *listen_cs = cf_item_to_section(ci);
CONF_SECTION *server_cs = cf_item_to_section(cf_parent(ci));
CONF_PAIR *namespace = cf_pair_find(server_cs, "namespace");
+ dl_t const *module;
if (DEBUG_ENABLED4) cf_log_debug(ci, "Loading proto_%s", cf_pair_value(namespace));
- if (!dl_module(listen_cs, NULL, cf_pair_value(namespace), DL_TYPE_PROTO)) {
+ module = dl_module(listen_cs, NULL, cf_pair_value(namespace), DL_TYPE_PROTO);
+ if (!module) {
cf_log_err(listen_cs, "Failed loading proto_%s module", cf_pair_value(namespace));
return -1;
}
+ cf_data_add(listen_cs, module, "proto module", true);
return 0;
}