text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   main.c                                             :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: jtoty <jtoty@student.42.fr>                +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2017/02/28 12:02:51 by jtoty             #+#    #+#             */
  /*   Updated: 2017/03/09 15:43:26 by jtoty            ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include <stdlib.h>
  #include <unistd.h>
  #include <string.h>
  #include "libft.h"
  
  static void		check_memset(void *mem, int c, int n, int mem_size)
  {
  	if (mem != ft_memset(mem, c, n))
  		write(1, "mem's adress was not returned\n", 30);
  	write(1, mem, mem_size);
  	free(mem);
  }
  
  int				main(int argc, const char *argv[])
  {
  	void	*mem;
  	int		arg;
  	int		mem_size;
  
  	alarm(5);
  	mem_size = 15;
  	if (!(mem = malloc(sizeof(*mem) * mem_size)) || argc == 1)
  		return (0);
  	memset(mem, 'j', mem_size);
  	if ((arg = atoi(argv[1])) == 1)
  		check_memset(mem, 'c', 5, mem_size);
  	else if (arg == 2)
  		check_memset(mem, 'c', 14, mem_size);
  	else if (arg == 3)
  		check_memset(mem, '\n', 6, mem_size);
  	else if (arg == 4)
  		check_memset(mem, '\0', 1, mem_size);
  	return (0);
  }
  