<commit_before>#include <stdio.h>
#include <stdlib.h>
#include "dbl_ptr.h"


struct leaf *create_leaf(void) {

    struct leaf *fresh_leaf = malloc(sizeof *fresh_leaf);
    fresh_leaf->parent = NULL;
    fresh_leaf->left = NULL;
    fresh_leaf->right = NULL;
    return fresh_leaf;
}

struct leaf *min_tree(struct leaf **tree) { 

    if (!((*tree)->left)) {
        return *tree;
    }
    return min_tree(&(*tree)->left);
}

void transplant(struct leaf **rm_branch, struct leaf **branch) {

    if (!(*rm_branch)->parent) { 
        if ((*rm_branch)->left) {
            (*rm_branch)->left->parent = *branch;
            (*branch)->left = (*rm_branch)->left;
        }
        (*branch)->parent = NULL;
        *rm_branch = *branch; 

    } else if (*rm_branch == (*rm_branch)->parent->left) {
        (*rm_branch)->parent->left = *branch;
        (*branch)->parent = (*rm_branch)->parent;
        (*branch)->parent->left = *branch;
    } else {
        if ((*rm_branch)->left && (*rm_branch)->left != *branch) {
            (*rm_branch)->left->parent = *branch;
            (*branch)->left = (*rm_branch)->left;
        }
        (*branch)->parent = (*rm_branch)->parent;
        (*rm_branch)->parent->right = *branch;
    }
}

void delete(struct leaf **tree, long value) {

    if (!(*tree)) {
        printf ("Value %ld not in tree!\n", value);

    } else if ((*tree)->value == value) {
        if ((!(*tree)->left) && (!(*tree)->right) && (!(*tree)->parent)) {
            free (*tree);
            *tree = NULL;

        } else if (!(*tree)->left && !(*tree)->right) {          
            if ((*tree)->parent->left && (*tree)->value == (*tree)->parent->left->value) {
                (*tree)->parent->left = NULL;

            } else {
                (*tree)->parent->right = NULL;
            }

        } else if (!(*tree)->left) {
            transplant(tree, &(*tree)->right); 

        } else if ((!(*tree)->right)) {
            transplant(tree, &(*tree)->left); 
<commit_msg>check for just parent<commit_after>#include <stdio.h>
#include <stdlib.h>
#include "dbl_ptr.h"


struct leaf *create_leaf(void) {

    struct leaf *fresh_leaf = malloc(sizeof *fresh_leaf);
    fresh_leaf->parent = NULL;
    fresh_leaf->left = NULL;
    fresh_leaf->right = NULL;
    return fresh_leaf;
}

struct leaf *min_tree(struct leaf **tree) { 

    if (!((*tree)->left)) {
        return *tree;
    }
    return min_tree(&(*tree)->left);
}

void transplant(struct leaf **rm_branch, struct leaf **branch) {

    if (!(*rm_branch)->parent) { 
        if ((*rm_branch)->left) {
            (*rm_branch)->left->parent = *branch;
            (*branch)->left = (*rm_branch)->left;
        }
        (*branch)->parent = NULL;
        *rm_branch = *branch; 

    } else if (*rm_branch == (*rm_branch)->parent->left) {
        (*rm_branch)->parent->left = *branch;
        (*branch)->parent = (*rm_branch)->parent;
        (*branch)->parent->left = *branch;
    } else {
        if ((*rm_branch)->left && (*rm_branch)->left != *branch) {
            (*rm_branch)->left->parent = *branch;
            (*branch)->left = (*rm_branch)->left;
        }
        (*branch)->parent = (*rm_branch)->parent;
        (*rm_branch)->parent->right = *branch;
    }
}

void delete(struct leaf **tree, long value) {

    if (!(*tree)) {
        printf ("Value %ld not in tree!\n", value);

    } else if ((*tree)->value == value) {
        if (!(*tree)->parent) {
            free (*tree);
            *tree = NULL;

        } else if (!(*tree)->left && !(*tree)->right) {          
            if ((*tree)->parent->left && (*tree)->value == (*tree)->parent->left->value) {
                (*tree)->parent->left = NULL;
            } else {
                (*tree)->parent->right = NULL;
            }

        } else if (!(*tree)->left) {
            transplant(tree, &(*tree)->right); 

        } else if ((!(*tree)->right)) {
            transplant(tree, &(*tree)->left); 

{'fraction_non_alphanumeric': 0.20759493670886076, 'fraction_numerical': 0.0, 'mean_word_length': 2.1684041700080194, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5141429', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1209, 'n_words': 251}