maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strndup.c File Reference
#include "libft.h"
Include dependency graph for ft_strndup.c:

Go to the source code of this file.

Functions

char * ft_strndup (const char *s, size_t n)
 

Function Documentation

◆ ft_strndup()

char * ft_strndup ( const char *  s,
size_t  n 
)

Definition at line 23 of file ft_strndup.c.

24{
25 size_t len;
26 char *new;
27
28 len = ft_strlen(s);
29 if (!s)
30 return (NULL);
31 new = malloc((n + 1) * sizeof(char));
32 if (!new)
33 return (NULL);
34 if (n > len)
35 n = len;
36 ft_strlcpy(new, s, n + 1);
37 return (new);
38}
size_t ft_strlcpy(char *dest, const char *src, size_t size)
Definition ft_strlcpy.c:25
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15

References ft_strlcpy(), and ft_strlen().

Referenced by add_env_node(), append_word_if_valid(), final_quote_removal(), and ft_remove_quotes().

Here is the call graph for this function:
Here is the caller graph for this function: