<commit_before>#include <stdlib.h>
#include <string.h>
#include "xalt_fgets_alloc.h"

const int SZ = 100;

int xalt_fgets_alloc(FILE *fp, char ** buffer, size_t* sz)
{
  char*  buf    = *buffer;
  size_t size   = *sz;
  size_t used   = 0;
  size_t needed = SZ;

  do {
    if (size < needed)
      {
	size = needed;
	char *buf_new = (char *)realloc(buf, size);
	if (buf_new == NULL)
	  {
	    // Out-of-memory
	    free(buf);
	    *sz     = 0;
	    *buffer = NULL;
	    return 0;
	  }
	buf	= buf_new;
	*sz	= size;<commit_msg>change default buffer size to 4096 (1 page)<commit_after>#include <stdlib.h>
#include <string.h>
#include "xalt_fgets_alloc.h"

const int SZ = 4096;

int xalt_fgets_alloc(FILE *fp, char ** buffer, size_t* sz)
{
  char*  buf    = *buffer;
  size_t size   = *sz;
  size_t used   = 0;
  size_t needed = SZ;

  do {
    if (size < needed)
      {
	size = needed;
	char *buf_new = (char *)realloc(buf, size);
	if (buf_new == NULL)
	  {
	    // Out-of-memory
	    free(buf);
	    *sz     = 0;
	    *buffer = NULL;
	    return 0;
	  }
	buf	= buf_new;
	*sz	= size;
{'fraction_non_alphanumeric': 0.1461609620721554, 'fraction_numerical': 0.016651248843663275, 'mean_word_length': 2.467948717948718, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3714775', 'n_tokens_mistral': 487, 'n_tokens_neox': 451, 'n_words': 116}