<commit_before>#include "HashTableAPI.h"

HTable *createTable(size_t size, int (*hashFunction)(size_t tableSize, int key),void (*destroyData)(void *data),void (*printData)(void *toBePrinted))
{

    int i;
    HTable * temp = malloc(sizeof(HTable));

    if(temp == NULL)
    {
        return NULL;
    }

    temp->table = malloc(sizeof(*temp->table) * size);

    for(i = 0; i < size; i++)
    {
        temp->table[i] = NULL;
    }

    temp->destroyData = destroyData;
    temp->hashFunction = hashFunction;
    temp->printData = printData;

    return temp;

}

Node *createNode(int key, void *data)
{

    Node * temp = malloc(sizeof(Node));

    if(temp == NULL)
    {
        return NULL;
    }

    temp->key = key;
    temp->data = data;
    temp->next = NULL;

    return temp;
}

void destroyTable(HTable *hashTable)
{

    Node * temp = NULL;

    while(temp != NULL)
    {
        removeData(hashTable, temp->key);
        temp = temp->next;
    }

    free(hashTable);

}

void insertData(HTable *hashTable, int key, void *data)
{

    int count;

    if(hashTable != NULL)
    {

        count = hashTable->hashFunction(hashTable->size, key);
        Node * temp = createNode(key, data);
        temp->next = hashTable->table[count];
        hashTable->table[count] = temp;

    }
}

void removeData(HTable *hashTable, int key)
{
	int count;

	count = hashTable->hashFunction(hashTable->size, key);

	if(hashTable != NULL)
	{

		Node * temp = hashTable->table[count];
		do 
		{
			if(temp->key == key)
			{
				free(temp->data);
				free (temp);
			}
			temp = temp->next;
		} while(temp->next != NULL);

	}
    
}

void *lookupData(HTable *hashTable, int key)
{

    int tempKey = 0;

    if (hashTable == NULL)
    {
        return NULL;<commit_msg>this remove doesnt break everything<commit_after>#include "HashTableAPI.h"

HTable *createTable(size_t size, int (*hashFunction)(size_t tableSize, int key),void (*destroyData)(void *data),void (*printData)(void *toBePrinted))
{

    int i;
    HTable * temp = malloc(sizeof(HTable));

    if(temp == NULL)
    {
        return NULL;
    }

    temp->table = malloc(sizeof(*temp->table) * size);

    for(i = 0; i < size; i++)
    {
        temp->table[i] = NULL;
    }

    temp->destroyData = destroyData;
    temp->hashFunction = hashFunction;
    temp->printData = printData;

    return temp;

}

Node *createNode(int key, void *data)
{

    Node * temp = malloc(sizeof(Node));

    if(temp == NULL)
    {
        return NULL;
    }

    temp->key = key;
    temp->data = data;
    temp->next = NULL;

    return temp;
}

void destroyTable(HTable *hashTable)
{

    Node * temp = NULL;

    while(temp != NULL)
    {
        removeData(hashTable, temp->key);
        temp = temp->next;
    }

    free(hashTable);

}

void insertData(HTable *hashTable, int key, void *data)
{

    int count;

    if(hashTable != NULL)
    {

        count = hashTable->hashFunction(hashTable->size, key);
        Node * temp = createNode(key, data);
        temp->next = hashTable->table[count];
        hashTable->table[count] = temp;

    }
}

void removeData(HTable *hashTable, int key)
{

    int tempKey = 0;

    if (hashTable != NULL)
    {


        tempKey = hashTable->hashFunction(hashTable->size, key);

        Node * temp = hashTable->table[tempKey];
        while(temp != NULL)
        {

            if(temp->key == tempKey)
            {
                free(temp->data);
            }
            temp = temp->next;
        }
    }
}

void *lookupData(HTable *hashTable, int key)
{

    int tempKey = 0;

    if (hashTable == NULL)
    {
        return NULL;
{'fraction_non_alphanumeric': 0.14513908014321122, 'fraction_numerical': 0.0013770311209033324, 'mean_word_length': 2.322964318389753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '4644976', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1200, 'n_words': 270}