This branch will contain functions that don't crash in cases in which the std functio...
authorLukas Jiriste <ljiriste@student.42prague.com>
Mon, 11 Sep 2023 11:17:47 +0000 (13:17 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Mon, 11 Sep 2023 11:17:47 +0000 (13:17 +0200)
This functionality may be useful but is held on separate branch in order to have "pure" std functionality also.

ft_strdup.c

index d16d5e05039b431c5410b480290c256da3c0c94a..1d5d1b6e8c262a7031c249684a983d77e36672c5 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/06/17 13:33:49 by ljiriste          #+#    #+#             */
-/*   Updated: 2023/08/15 12:52:18 by ljiriste         ###   ########.fr       */
+/*   Updated: 2023/09/11 12:37:12 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -18,6 +18,8 @@ char  *ft_strdup(const char *s)
        char    *dest;
        size_t  s_len;
 
+       if (s == NULL)
+               return (NULL);
        s_len = ft_strlen(s);
        dest = malloc((s_len + 1) * sizeof(char));
        if (dest)