<commit_before>#include "list.h"
#include <stdlib.h>

simplet_list_t*
simplet_list_new(){
  simplet_list_t* list;
  if(!(list = malloc(sizeof(*list))))
    return NULL;
  list->head   = NULL;
  list->tail   = NULL;
  list->free   = NULL;
  list->length = 0;
  
  return list;
}

void*
simplet_list_push(simplet_list_t *list, void* val){
  simplet_node_t *node;
  
  if(!(node = malloc(sizeof(*node)))) 
    return NULL;
  node->value = val;
  
  if(!(list->head || list->tail)) {
    list->head = list->tail = node;
    node->next = node->prev = NULL;
  } else {
    node->next = NULL;
    node->prev = list->tail;
    list->tail->next = node;
    list->tail = node;
  }
  
  list->length++;
  return val;
}

// TODO: Fix this so as not to rely on length
void*
simplet_list_pop(simplet_list_t *list){
  if(list->length <= 0) return NULL;

  simplet_node_t *node = list->tail;
  void *val = node->value;
  
  if(--list->length) {
    list->tail = node->prev;
    list->tail->next = node->next;
  } else {
    list->tail = list->head = NULL;
  }

  //list->length--;
  free(node);
  return val;
}

void
simplet_list_free(simplet_list_t *list){
  void* val;
  while((val = simplet_list_pop(list)) != NULL)
    if(list->free) list->free(val);
  free(list);
}

simplet_listiter_t*
simplet_get_list_iter(simplet_list_t *list){
  simplet_listiter_t* iter;
  if(!(iter = malloc(sizeof(*iter))))
    return NULL;
  iter->next = list->head;
  return iter;
}

void*
simplet_get_next(simplet_listiter_t* iter){
  simplet_node_t *current = iter->next;
  if(current != NULL) {
    iter->next = current->next;
    return current->value;
  } else {
    free(iter);
  }
  return NULL;
}



<commit_msg>fixed up the list to not rely on length<commit_after>#include "list.h"
#include <stdlib.h>

simplet_list_t*
simplet_list_new(){
  simplet_list_t* list;
  if(!(list = malloc(sizeof(*list))))
    return NULL;
  list->head   = NULL;
  list->tail   = NULL;
  list->free   = NULL;
  list->length = 0;
  
  return list;
}

void*
simplet_list_push(simplet_list_t *list, void* val){
  simplet_node_t *node;
  
  if(!(node = malloc(sizeof(*node)))) 
    return NULL;
  node->value = val;
  
  if(!(list->head || list->tail)) {
    list->head = list->tail = node;
    node->next = node->prev = NULL;
  } else {
    node->next = NULL;
    node->prev = list->tail;
    list->tail->next = node;
    list->tail = node;
  }
  
  list->length++;
  return val;
}

void*
simplet_list_pop(simplet_list_t *list){
  if(!(list->head || list->tail)) return NULL;

  simplet_node_t *node = list->tail;
  void *val = node->value;
  
  if (node->prev)
    node->prev->next = NULL;
  else
    list->head = NULL;

  list->tail = node->prev;

  free(node);
  list->length--;
  return val;
}

void
simplet_list_free(simplet_list_t *list){
  void* val;
  while((val = simplet_list_pop(list)) != NULL)
    if(list->free) list->free(val);
  free(list);
}

simplet_listiter_t*
simplet_get_list_iter(simplet_list_t *list){
  simplet_listiter_t* iter;
  if(!(iter = malloc(sizeof(*iter))))
    return NULL;
  iter->next = list->head;
  return iter;
}

void*
simplet_get_next(simplet_listiter_t* iter){
  simplet_node_t *current = iter->next;
  if(current != NULL) {
    iter->next = current->next;
    return current->value;
  } else {
    free(iter);
  }
  return NULL;
}




{'fraction_non_alphanumeric': 0.16691729323308271, 'fraction_numerical': 0.0009022556390977444, 'mean_word_length': 3.2805662805662807, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 80, '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': '3972520', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1283, 'n_words': 260}