<commit_before>#include <stdlib.h>
#include <cpl_error.h>

#include "style.h"
#include "query.h"
#include "util.h"
#include "list.h"
#include "map.h"
#include "bounds.h"
#include "text.h"
#include "error.h"
#include "memory.h"

// Set up some user data functions.
SIMPLET_HAS_USER_DATA(query)

// Create and initialize a query.
simplet_query_t *
simplet_query_new(const char *sqlquery){
  simplet_query_t *query;
  if(!(query = malloc(sizeof(*query))))
    return NULL;

  memset(query, 0, sizeof(*query));

  if(!(query->styles = simplet_list_new())){
    free(query);
    return NULL;
  }

  query->status = SIMPLET_OK;
  query->ogrsql       = simplet_copy_string(sqlquery);

  simplet_retain((simplet_retainable_t *)query);
  return query;
}

// Free a void pointer pointing to a query.
void
simplet_query_vfree(void *query){
  simplet_query_free(query);
}


// Free a layer and associated queries.
void
simplet_query_free(simplet_query_t *query){
  if(simplet_release((simplet_retainable_t *)query) > 0) return;
  if(query->error_msg) free(query->error_msg);

  simplet_list_t* styles = query->styles;
  simplet_list_set_item_free(styles, simplet_style_vfree);
  simplet_list_free(styles);
  free(query->ogrsql);
  free(query);
}

// Add an error function.
SIMPLET_ERROR_FUNC(query_t)

// Set the OGR SQL on this query.
simplet_status_t<commit_msg>spacing<commit_after>#include <stdlib.h>
#include <cpl_error.h>

#include "style.h"
#include "query.h"
#include "util.h"
#include "list.h"
#include "map.h"
#include "bounds.h"
#include "text.h"
#include "error.h"
#include "memory.h"

// Set up some user data functions.
SIMPLET_HAS_USER_DATA(query)

// Create and initialize a query.
simplet_query_t *
simplet_query_new(const char *sqlquery){
  simplet_query_t *query;
  if(!(query = malloc(sizeof(*query))))
    return NULL;

  memset(query, 0, sizeof(*query));

  if(!(query->styles = simplet_list_new())){
    free(query);
    return NULL;
  }

  query->status = SIMPLET_OK;
  query->ogrsql = simplet_copy_string(sqlquery);

  simplet_retain((simplet_retainable_t *)query);
  return query;
}

// Free a void pointer pointing to a query.
void
simplet_query_vfree(void *query){
  simplet_query_free(query);
}


// Free a layer and associated queries.
void
simplet_query_free(simplet_query_t *query){
  if(simplet_release((simplet_retainable_t *)query) > 0) return;
  if(query->error_msg) free(query->error_msg);

  simplet_list_t* styles = query->styles;
  simplet_list_set_item_free(styles, simplet_style_vfree);
  simplet_list_free(styles);
  free(query->ogrsql);
  free(query);
}

// Add an error function.
SIMPLET_ERROR_FUNC(query_t)

// Set the OGR SQL on this query.
simplet_status_t
{'fraction_non_alphanumeric': 0.13447251114413075, 'fraction_numerical': 0.0014858841010401188, 'mean_word_length': 5.051685393258427, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '6107106', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1003, 'n_words': 215}