<commit_before>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strsplit_tolst.c                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: ncoden <<EMAIL>>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2014/11/07 11:15:04 by ncoden            #+#    #+#             */
/*   Updated: 2014/11/07 16:55:57 by ncoden           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"

t_lst	*ft_strsplit_tolst(const char *s, char c)
{
	size_t		i;
	size_t		size_word;
	t_lst		*lst;

	i = 0;
	size_word = 0;
	lst = NULL;
	while (i == 0 || (i > 0 && s[i - 1] != '\0'))
	{
		if ((s[i] == '\0' || s[i] == c) && size_word > 0)
		{
			ft_lstpushback(&lst,
				(void*)ft_strsub(s, i - size_word, size_word), size_word + 1);
			size_word = 0;
		}
		if (s[i] != c)
			size_word++;
		i++;
	}
	return (lst);
}
<commit_msg>ft_strsplit_tolst - Fix memory leak<commit_after>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strsplit_tolst.c                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: ncoden <<EMAIL>>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2014/11/07 11:15:04 by ncoden            #+#    #+#             */
/*   Updated: 2015/05/13 16:00:13 by ncoden           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"

t_lst	*ft_strsplit_tolst(const char *s, char c)
{
	size_t		i;
	size_t		size_word;
	t_lst		*lst;

	i = 0;
	size_word = 0;
	lst = NULL;
	while (i == 0 || (i > 0 && s[i - 1] != '\0'))
	{
		if ((s[i] == '\0' || s[i] == c) && size_word > 0)
		{
			ft_lstlnback(&lst,
				(void*)ft_strsub(s, i - size_word, size_word), size_word + 1);
			size_word = 0;
		}
		if (s[i] != c)
			size_word++;
		i++;
	}
	return (lst);
}

{'fraction_non_alphanumeric': 0.2798369162342476, 'fraction_numerical': 0.028169014084507043, 'mean_word_length': 1.0477996965098635, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2105585', 'n_tokens_mistral': 921, 'n_tokens_neox': 808, 'n_words': 137}