<commit_before>/* This is free and unencumbered software released into the public domain.  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"

#define TRUE 1
#define FALSE 0

char* escape(const char *message) {
    int i, count = 0, length_orig = strlen(message);
    for (i = 0; i < length_orig; i++) {
        if (strchr("\"\\", message[i])) {
            count++;
        }
    }
    char *copy = malloc(length_orig + count + 1);
    char *p = copy;
    while (*message) {
        if (strchr("\"\\", *message)) {
            *p = '\\';
            p++;
        }
        *p = *message;
        message++;
        p++;
    }
    *p = '\0';
    return copy;
}

void send_error(int code, const char *message) {
    char *escaped = escape(message);
    printf("error %d \"%s\"\n", code, escaped);
    free(escaped);
}

typedef struct {
    char *buffer;
    size_t size;
} buffer;

buffer* buffer_create() {
    buffer *buffer = malloc(sizeof(buffer));
    buffer->size = 4096;
    buffer->buffer = malloc(buffer->size * sizeof(char));
    return buffer;
}

int buffer_grow(buffer *buffer) {<commit_msg>Fix buffer struct allocation size (fixes #91)<commit_after>/* This is free and unencumbered software released into the public domain.  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"

#define TRUE 1
#define FALSE 0

char* escape(const char *message) {
    int i, count = 0, length_orig = strlen(message);
    for (i = 0; i < length_orig; i++) {
        if (strchr("\"\\", message[i])) {
            count++;
        }
    }
    char *copy = malloc(length_orig + count + 1);
    char *p = copy;
    while (*message) {
        if (strchr("\"\\", *message)) {
            *p = '\\';
            p++;
        }
        *p = *message;
        message++;
        p++;
    }
    *p = '\0';
    return copy;
}

void send_error(int code, const char *message) {
    char *escaped = escape(message);
    printf("error %d \"%s\"\n", code, escaped);
    free(escaped);
}

typedef struct {
    char *buffer;
    size_t size;
} buffer;

buffer* buffer_create() {
    buffer *buffer = malloc(sizeof(*buffer));
    buffer->size = 4096;
    buffer->buffer = malloc(buffer->size * sizeof(char));
    return buffer;
}

int buffer_grow(buffer *buffer) {
{'fraction_non_alphanumeric': 0.16587060356057318, 'fraction_numerical': 0.010421189752496743, 'mean_word_length': 2.4133333333333336, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '4776853', 'n_tokens_mistral': 802, 'n_tokens_neox': 763, 'n_words': 218}