/* * Close the connection and release memory */ static void my_con_free(db_con_t* con, struct my_con* payload) { if (!payload) return; /* Delete the structure only if there are no more references * to it in the connection pool */ if (db_pool_remove((db_pool_entry_t*)payload) == 0) return; db_pool_entry_free(&payload->gen); if (payload->con) pkg_free(payload->con); pkg_free(payload); }
/** Free all memory allocated for a bdb_con structure. * This function function frees all memory that is in use by * a bdb_con structure. * @param con A generic db_con connection structure. * @param payload BDB specific payload to be freed. */ static void bdb_con_free(db_con_t* con, bdb_con_t *payload) { if (!payload) return; /* Delete the structure only if there are no more references * to it in the connection pool */ if (db_pool_remove((db_pool_entry_t*)payload) == 0) return; db_pool_entry_free(&payload->gen); /* destroy and free BDB env */ pkg_free(payload); }
/** Free all memory allocated for a ld_con structure. * This function function frees all memory that is in use by * a ld_con structure. * @param con A generic db_con connection structure. * @param payload LDAP specific payload to be freed. */ static void ld_con_free(db_con_t* con, struct ld_con* payload) { struct ld_uri* luri; int ret; if (!payload) return; luri = DB_GET_PAYLOAD(con->uri); /* Delete the structure only if there are no more references * to it in the connection pool */ if (db_pool_remove((db_pool_entry_t*)payload) == 0) return; db_pool_entry_free(&payload->gen); if (payload->con) { ret = ldap_unbind_ext_s(payload->con, NULL, NULL); if (ret != LDAP_SUCCESS) { ERR("ldap: Error while unbinding from %s: %s\n", luri->uri, ldap_err2string(ret)); } } pkg_free(payload); }