Example #1
0
static void destroy_mustache_list(mustache_value_t* value)
{
    mustache_context_t** m_list_ctxs = value->data.list;
    for (size_t i = 0; i < value->length; i++) {
        m_list_ctxs[i]->destroy(m_list_ctxs[i]);
    }
    mustache_free(value);
}
Example #2
0
static void free_global_data(global_data_t *global_data)
{
	if (global_data->global_thread_data) {
		for (size_t i = 1; i < global_data->global_thread_data->config->thread_num; i++)
			CHECK_ERROR(pthread_join, global_data->global_thread_data[i].thread, NULL);

		free(global_data->global_thread_data);
	}

	if (global_data->file_logger)
		global_data->file_logger->dispose(global_data->file_logger);

	if (global_data->fortunes_template) {
		mustache_api_t api = {.freedata = NULL};

		mustache_free(&api, global_data->fortunes_template);
	}
Example #3
0
mustache_template_t *get_fortunes_template(const char *path)
{
	mustache_template_t *ret = NULL;
	template_input_t template_input = {.input = fopen(path, "rb"), .name = path};

	if (template_input.input) {
		mustache_api_t api = {.error = template_error,
		                      .read = read_template,
		                      .sectget = prerender_section,
		                      .varget = prerender_variable};
		bool in_section = false;

		ret = mustache_compile(&api, &template_input);

		if (ret && !mustache_prerender(&api, &in_section, ret)) {
			mustache_free(&api, ret);
			ret = NULL;
		}

		fclose(template_input.input);
	}
	else
Example #4
0
static void destroy_mustache_value(mustache_value_t* value)
{
    mustache_free(value);
}
Example #5
0
static void destroy_mustache_object(mustache_value_t* value)
{
    mustache_value_t* m_value = (mustache_value_t*) value;
    m_value->data.object->destroy(m_value->data.object);
    mustache_free(m_value);
}
Example #6
0
void destroy_mustache_context(mustache_context_t* m_ctx)
{
    mustache_free(m_ctx);
}