create main.c and utils and create alloc utilc and prepare parser

This commit is contained in:
Denis 2021-05-09 13:45:10 +03:00
parent 4f718d18ef
commit ad6600d071
3 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#ifndef PHILO_HEADER_H
# define PHILO_HEADER_H
# include <stdlib.h>
# include <unistd.h>
# include <pthread.h>
# include <sys/time.h>
# include <stdio.h>
typedef struct s_all
{
int number_of_philosophers;
int time_to_die;
int time_to_eat;
int time_to_sleep;
int number_of_times_each_philosopher_must_eat;
} t_all;
void *ft_calloc(size_t num, size_t size);
t_all *structalloc_and_bzero(void);
int parse_and_check_values(char **argv, int quantity);
#endif

View File

@ -0,0 +1,15 @@
#include "../includes/philo_header.h"
int parse_and_check_values(char **argv, int quantity)
{
t_all *all;
all = structalloc_and_bzero();
}
int main(int argc, char **argv)
{
}

31
philo_one/srcs/utilc.c Normal file
View File

@ -0,0 +1,31 @@
#include "../includes/philo_header.h"
void *ft_calloc(size_t num, size_t size)
{
void *addr;
unsigned int nbytes;
nbytes = num * size;
addr = malloc(nbytes);
if (!size || !num || (size == 0 && num == 0))
return ((void *)addr);
if (!addr)
return (NULL);
else
{
memset(addr, '\0', nbytes);
}
return ((void *)addr);
}
t_all *structalloc_and_bzero(void)
{
t_all *all;
all = ft_calloc(sizeof(t_all), 1);
all->number_of_philosophers = 0;
all->time_to_die = 0;
all->time_to_eat = 0;
all->time_to_sleep = 0;
all->number_of_times_each_philosopher_must_eat = 0;
}