minishell
ft_strdup.c File Reference
#include <stdlib.h>
#include "ft_string.h"
Include dependency graph for ft_strdup.c:

Go to the source code of this file.

Functions

char * ft_strdup (const char *s1)
 

Function Documentation

◆ ft_strdup()

char* ft_strdup ( const char *  s1)

Definition at line 16 of file ft_strdup.c.

17 {
18  size_t s1_len;
19  char *p_ret;
20  char *p_ret_top;
21 
22  s1_len = ft_strlen(s1);
23  p_ret = (char *)malloc(s1_len + 1);
24  p_ret_top = p_ret;
25  if (p_ret == NULL)
26  return (NULL);
27  while (*s1 != '\0')
28  *p_ret++ = *s1++;
29  *p_ret = '\0';
30  return (p_ret_top);
31 }
size_t ft_strlen(const char *s)
Definition: ft_strlen.c:15
Here is the call graph for this function:
Here is the caller graph for this function: