void acl_cfg_parser_free(ACL_CFG_PARSER *parser) { if (parser) { if (parser->_cfg_array) acl_array_destroy(parser->_cfg_array, _cfg_line_free); acl_myfree(parser); } }
void acl_netdb_free(ACL_DNS_DB *h_dns_db) { if (h_dns_db == NULL) return; if (h_dns_db->h_db) acl_array_destroy(h_dns_db->h_db, free_dns_db); acl_myfree(h_dns_db); }
/*----------------------------------------------------------------------------*/ static void __dbpool_mysql_destroy(ACL_DB_POOL *db_pool) { ACL_DB_POOL_MYSQL *mysql_pool; ACL_DB_HANDLE_MYSQL *mysql_handle; int i, n; mysql_pool = (ACL_DB_POOL_MYSQL *) db_pool; n = acl_array_size(mysql_pool->handles); for (i = 0; i < n; i++) { mysql_handle = (ACL_DB_HANDLE_MYSQL *) acl_array_index(mysql_pool->handles, i); if (mysql_handle == NULL) continue; __close_mysql_handle(mysql_handle); acl_myfree(mysql_handle); } acl_pthread_mutex_destroy(&mysql_pool->mutex); acl_array_destroy(mysql_pool->handles, NULL); acl_myfree(mysql_pool); mysql_library_end(); }
static ACL_CFG_LINE *_create_cfg_line(char *data, const char *delimiter) { ACL_CFG_LINE *cfg_line = NULL; ACL_ARRAY *a = NULL; int i, n; char *ptr, *pdata, *pitem; #undef ERETURN #define ERETURN(x) do { \ if (a) \ acl_array_destroy(a, acl_myfree_fn); \ if (cfg_line) { \ if (cfg_line->value) \ acl_myfree(cfg_line); \ acl_myfree(cfg_line); \ } \ return (x); \ } while (0); if (data == NULL) return (NULL); pdata = data; cfg_line = (ACL_CFG_LINE *) acl_mycalloc(1, sizeof(ACL_CFG_LINE)); if (cfg_line == NULL) return (NULL); a = acl_array_create(10); while (1) { ptr = acl_mystrtok(&pdata, delimiter); if (ptr == NULL) break; pitem = acl_mystrdup(ptr); if (pitem == NULL) { ERETURN (NULL); } if (acl_array_append(a, (void *) pitem) < 0) { ERETURN (NULL); } } cfg_line->ncount = 0; cfg_line->pdata = NULL; n = acl_array_size(a); if (n > 0) { cfg_line->value = (char **) acl_mycalloc(1 + n, sizeof(char *)); if (cfg_line->value == NULL) { ERETURN (NULL); } for (i = 0; i < n; i++) { pitem = (char *) acl_array_index(a, i); if (pitem == NULL) break; cfg_line->value[i] = pitem; if (cfg_line->value[i] == NULL) ERETURN (NULL); cfg_line->ncount++; } } /* NOTICE: in acl_array_destroy, please don't input acl_myfree, but * NULL as the second parameter, because the mystrup's result * set are stored in cfg_line->value now:) */ acl_array_destroy(a, NULL); return (cfg_line); }
void acl_xml3_free_array(ACL_ARRAY *a) { acl_array_destroy(a, NULL); }