ft_malloc can use print for error msg

This commit is contained in:
Jack Halford 2017-03-23 18:26:28 +01:00
parent d8c0807f12
commit 784d201914
5 changed files with 9 additions and 8 deletions

View file

@ -6,14 +6,14 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/23 17:01:20 by ariard ### ########.fr # # Updated: 2017/03/23 18:17:44 by jhalford ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
NAME = 42sh NAME = 42sh
CC = gcc CC = gcc
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden -fsanitize=address FLAGS = -Wall -Wextra -Werror -fvisibility=hidden
D_FLAGS = -g D_FLAGS = -g
DELTA = $$(echo "$$(tput cols)-47"|bc) DELTA = $$(echo "$$(tput cols)-47"|bc)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/21 15:45:00 by jhalford #+# #+# */ /* Created: 2017/03/21 15:45:00 by jhalford #+# #+# */
/* Updated: 2017/03/21 16:34:03 by jhalford ### ########.fr */ /* Updated: 2017/03/23 18:25:12 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ void *ft_malloc(size_t size)
ptr = malloc(size); ptr = malloc(size);
if (!ptr) if (!ptr)
{ {
ft_dprintf(2, "{red}%s{eoc}", strerror(errno)); ft_putstrfd(strerror(errno), 2);
exit(errno); exit(errno);
} }
return (ptr); return (ptr);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:04:07 by jhalford #+# #+# */ /* Created: 2016/11/03 18:04:07 by jhalford #+# #+# */
/* Updated: 2017/03/23 18:07:14 by jhalford ### ########.fr */ /* Updated: 2017/03/23 18:18:07 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/22 22:08:20 by jhalford ### ########.fr */ /* Updated: 2017/03/23 18:18:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */
/* Updated: 2017/03/23 18:06:47 by jhalford ### ########.fr */ /* Updated: 2017/03/23 18:24:41 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,7 +28,8 @@ int builtin_unsetenv(const char *path, char *const av[], char *const envp[])
j = 0; j = 0;
while (*env && (*env)[j]) while (*env && (*env)[j])
{ {
if (ft_strcmp((*env)[j], av[i]) == '=') if (ft_strcmp((*env)[j], av[i]) == '='
&& ft_strlen(av[1]) == ft_strlenchr((*env)[i], '='))
ft_sstrdel(*env, j); ft_sstrdel(*env, j);
else else
j++; j++;