<commit_before>/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "iostream-internal.h"

static void
io_stream_default_close_destroy(struct iostream_private *stream ATTR_UNUSED)
{
}

void io_stream_init(struct iostream_private *stream)
{
	if (stream->close == NULL)
		stream->close = io_stream_default_close_destroy;
	if (stream->destroy == NULL)
		stream->destroy = io_stream_default_close_destroy;

	stream->refcount = 1;
}

void io_stream_ref(struct iostream_private *stream)
{
	stream->refcount++;
}

void io_stream_unref(struct iostream_private *stream)
{
	i_assert(stream->refcount > 0);
	if (--stream->refcount != 0)
		return;

	stream->close(stream);
	if (stream->destroy_callback != NULL)
		stream->destroy_callback(stream->destroy_context);
	stream->destroy(stream);

        i_free(stream->name);
        i_free(stream);
}

void io_stream_close(struct iostream_private *stream)
{
	stream->close(stream);
}

void io_stream_set_max_buffer_size(struct iostream_private *stream,
				   size_t max_size)
{
	stream->set_max_buffer_size(stream, max_size);
}<commit_msg>iostream: Call destroy callback after the destroy() method is called.<commit_after>/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "iostream-internal.h"

static void
io_stream_default_close_destroy(struct iostream_private *stream ATTR_UNUSED)
{
}

void io_stream_init(struct iostream_private *stream)
{
	if (stream->close == NULL)
		stream->close = io_stream_default_close_destroy;
	if (stream->destroy == NULL)
		stream->destroy = io_stream_default_close_destroy;

	stream->refcount = 1;
}

void io_stream_ref(struct iostream_private *stream)
{
	stream->refcount++;
}

void io_stream_unref(struct iostream_private *stream)
{
	i_assert(stream->refcount > 0);
	if (--stream->refcount != 0)
		return;

	stream->close(stream);
	stream->destroy(stream);
	if (stream->destroy_callback != NULL)
		stream->destroy_callback(stream->destroy_context);

        i_free(stream->name);
        i_free(stream);
}

void io_stream_close(struct iostream_private *stream)
{
	stream->close(stream);
}

void io_stream_set_max_buffer_size(struct iostream_private *stream,
				   size_t max_size)
{
	stream->set_max_buffer_size(stream, max_size);
}
{'fraction_non_alphanumeric': 0.12045060658578856, 'fraction_numerical': 0.009532062391681109, 'mean_word_length': 5.616045845272207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '7086302', 'n_tokens_mistral': 823, 'n_tokens_neox': 779, 'n_words': 155}