<commit_before>
(declare (unit jansson))

(foreign-declare "

#include <jansson.h>

// allocates a json_error on the heap
json_error_t* malloc_json_error()
{
  json_error_t* json_error = malloc(sizeof(json_error_t));
  return json_error;
}

// frees the specified json_error
void free_json_error(json_error_t* json_error)
{
  free(json_error);
}

// the result of the wrapped json_dumps function
struct json_dumps_result_t
{
  char* value;
};

// wraps the json_dumps function
// returns an opaque heap pointer to scheme
struct json_dumps_result_t* json_dumps_wrapped(json_t* json)
{
  char* value = json_dumps(json, JSON_INDENT(2) | JSON_PRESERVE_ORDER);
  if (value == NULL)
  {
    return NULL;
  }

  struct json_dumps_result_t* json_dumps_result = malloc(sizeof(struct json_dumps_result_t));
  json_dumps_result->value = value;<commit_msg>Protected a malloc in jansson ffi<commit_after>
(declare (unit jansson))

(foreign-declare "

#include <jansson.h>

// allocates a json_error on the heap
json_error_t* malloc_json_error()
{
  json_error_t* json_error = malloc(sizeof(json_error_t));
  return json_error;
}

// frees the specified json_error
void free_json_error(json_error_t* json_error)
{
  free(json_error);
}

// the result of the wrapped json_dumps function
struct json_dumps_result_t
{
  char* value;
};

// wraps the json_dumps function
// returns an opaque heap pointer to scheme
struct json_dumps_result_t* json_dumps_wrapped(json_t* json)
{
  char* value = json_dumps(json, JSON_INDENT(2) | JSON_PRESERVE_ORDER);
  if (value == NULL)
  {
    return NULL;
  }

  struct json_dumps_result_t* json_dumps_result = malloc(sizeof(struct json_dumps_result_t));
  if (json_dumps_result == NULL)
  {
    return NULL;
  }

  json_dumps_result->value = value;
{'fraction_non_alphanumeric': 0.0967741935483871, 'fraction_numerical': 0.0011318619128466328, 'mean_word_length': 4.9932203389830505, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4026895', 'n_tokens_mistral': 666, 'n_tokens_neox': 644, 'n_words': 151}