aboutsummaryrefslogtreecommitdiffstats
path: root/libft/src/ft_strlcat.c
blob: d9588e64d2e9ee3527f6835cc23bd2444f94f1d0 (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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strlcat.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: joelecle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:07:10 by joelecle          #+#    #+#             */
/*   Updated: 2020/02/14 17:07:10 by joelecle         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

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

size_t
	ft_strlcat(char *dst, const char *src, size_t size)
{
	size_t dst_len;

	dst_len = ft_strnlen(dst, size);
	if (dst_len == size)
		return (dst_len + ft_strlen(src));
	return (dst_len + ft_strlcpy(dst + dst_len, src, size - dst_len));
}