aboutsummaryrefslogtreecommitdiffstats
path: root/libft/src/ft_printf_cat_output.c
blob: f340109d538e71b7531bac96a25ede6e0dab2959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_printf_cat_output.c                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:06:43 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:06:43 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <stddef.h>
#include <unistd.h>

void
	ft_printf_cat_output(char *src, size_t len, t_printflist *pflist)
{
	size_t	dst_len;

	dst_len = pflist->fulllen;
	pflist->output = (char*)ft_nrealloc(pflist->output,
										(dst_len + 1) * sizeof(char),
										(dst_len + len + 1) * sizeof(char));
	ft_memcpy(pflist->output + dst_len, src, len);
	*(pflist->output + dst_len + len) = '\0';
	pflist->fulllen += len;
}