<commit_before>//
// Copyright 2016 <NAME> <<EMAIL>>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

#include "core/nng_impl.h"
#include <stdlib.h>
#include <stdio.h>

static int
nni_init_helper(void)
{
	int rv;

	if ((rv = nni_taskq_sys_init()) != 0) {
		return (rv);
	}
	if ((rv = nni_timer_sys_init()) != 0) {
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_random_sys_init()) != 0) {
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_sock_sys_init()) != 0) {
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_ep_sys_init()) != 0) {
		nni_sock_sys_fini();
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_pipe_sys_init()) != 0) {
		nni_ep_sys_fini();
		nni_sock_sys_fini();
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	nni_tran_sys_init();
	return (0);
}


int
nni_init(void)
{
	return (nni_plat_init(nni_init_helper));
}


void
nni_fini(void)
{
	// XXX: We should make sure that underlying sockets and
	// file descriptors are closed.  Details TBD.
	nni_tran_sys_fini();
	nni_ep_sys_fini();
	nni_sock_sys_fini();
	nni_random_sys_fini();
	nni_timer_sys_fini();
	nni_taskq_sys_fini();
	nni_plat_fini();
}
<commit_msg>Clean up the pipe system (no leaks).<commit_after>//
// Copyright 2016 <NAME> <<EMAIL>>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

#include "core/nng_impl.h"
#include <stdlib.h>
#include <stdio.h>

static int
nni_init_helper(void)
{
	int rv;

	if ((rv = nni_taskq_sys_init()) != 0) {
		return (rv);
	}
	if ((rv = nni_timer_sys_init()) != 0) {
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_random_sys_init()) != 0) {
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_sock_sys_init()) != 0) {
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_ep_sys_init()) != 0) {
		nni_sock_sys_fini();
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	if ((rv = nni_pipe_sys_init()) != 0) {
		nni_ep_sys_fini();
		nni_sock_sys_fini();
		nni_random_sys_fini();
		nni_timer_sys_fini();
		nni_taskq_sys_fini();
		return (rv);
	}
	nni_tran_sys_init();
	return (0);
}


int
nni_init(void)
{
	return (nni_plat_init(nni_init_helper));
}


void
nni_fini(void)
{
	// XXX: We should make sure that underlying sockets and
	// file descriptors are closed.  Details TBD.
	nni_tran_sys_fini();
	nni_pipe_sys_fini();
	nni_ep_sys_fini();
	nni_sock_sys_fini();
	nni_random_sys_fini();
	nni_timer_sys_fini();
	nni_taskq_sys_fini();
	nni_plat_fini();
}

{'fraction_non_alphanumeric': 0.14995193848125601, 'fraction_numerical': 0.007049022749118872, 'mean_word_length': 4.364261168384879, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '7271370', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1368, 'n_words': 281}