int entlim_free_ctx(void *ctx, void free_leaf(void *)) { pbs_entlim_key_t *leaf; int rc; leaf = entlim_create_key(NULL); /* alloc space for max sized key */ if (leaf == NULL) return -1; avl_first_key((AVL_IX_DESC *)ctx); while ((rc = avl_next_key((AVL_IX_REC *)leaf, (AVL_IX_DESC *)ctx)) == AVL_IX_OK) { free_leaf(leaf->recptr); } free(leaf); avl_destroy_index((AVL_IX_DESC *)ctx); free(ctx); return 0; }
/** * @brief Destroy the global AVL tree of environment variables created by * create_env_avltree in global variable called "env_avltree" * * @return void * * @retval None */ void destroy_env_avltree() { AVL_IX_REC *pe = NULL; int ret = 0; if (env_avltree != NULL) { avl_first_key(env_avltree); if ((pe = malloc(sizeof(AVL_IX_REC) + WINLOG_BUF_SIZE + 1)) != NULL) { while ((ret = avl_next_key(pe, env_avltree)) == AVL_IX_OK) { free(pe->recptr); pe->recptr = NULL; avl_delete_key(pe, env_avltree); } free(pe); pe = NULL; } avl_destroy_index(env_avltree); free(env_avltree); env_avltree = NULL; } }